Sort from sql using java?

I have the following problem, which may (I hope) have a standard solution.
I have a Java application that interacts with a database and builds SQL strings dynamically.
So far, I assume that the usual stuff.
Sometimes I have to sort the data and I use ORDER By . I still think. Problem: I sometimes have to sort by a column that has no actual data, and a short row that is the key to the actual data.
I mean:
SELECT FROM MYTable WHERE MyTable.col1 = 'A' ORDER BY MyTable.col2 ASC
And col2 has values: AB , BY , CY , which return the sorted ones, but are useless to me, since they are keys to the actual values ​​from the properties file and therefore the final result is not sorted.
What is the best way to solve this problem according to how it currently works?

0
source share
1 answer

If there is no data in the database, then your choice is either to sort it in Java, or first insert the data from the properties file into a temporary table, and then join this table and execute ORDER BY in SQL. If this is an operation that happens frequently, you might consider putting properties in a permanent table.

+5
source

Source: https://habr.com/ru/post/1442003/


All Articles