I'm using the following in my CommandText
property of the DataSet
I'm using:
SELECT *
FROM table_name
ORDER BY FIELD(priority, 'urgent', 'normal'),
FIELD(state, 'wait', 'executed', 'done')
It should sort the data I'm displaying in the DBGrid
connected to this DataSet
, like this:
- Rows containing
urgent
in thepriority
column should start the DBGrid list. - Then the list should continue with the ones marked as
normal
in thepriority
column,
- Rows containing
- followed by the ones marked as
wait
in thestate
column, - followed by the ones marked as
executed
in thestate
column, - and finally the list ends with the ones marked as
done
in thestate
column.
- followed by the ones marked as
But It doesn't, well actually it kind of does, but it's actually backwards. Here is a quick video I've made to show you whats happening, maybe you can get a clearer view this way:
I'm guessing it's because of either the ID column
I'm using or the Date column
but if so, I have no idea how and why.
This is how those 2 columns look like/are set up:
- ID column is set as Primary and Unique and Auto_Increment - that's it, no Index or any of the other options If it's not those 2 columns the problem, then maybe the DBGrid?
I'm using RAD Studio 10 Seattle, dbExpress components (TSimpleDataSet, etc) and MySQL db
Any thoughts on how to fix this? thanks!