Troy2000
-
Posts
3 -
Joined
-
Last visited
Posts posted by Troy2000
-
-
I tried this:
ORDER BY zone ASC, Id DESC LIMIT 3
or just:
ORDER BY zone, Id DESC LIMIT 3
Which gives me:
Unit01
Unit01
Unit01
ORDER BY Id DESC LIMIT 3, zone ASC
or just:
ORDER BY Id DESC LIMIT 3, zone
I get: error Undeclared variable: zone
Am I not sorting by zone correctly?
Thanks
Troy
-
I have been looking for an answer to a problem with sorting all day and cannot seem to find the correct answer. The following is my sql query:
SELECT Id, zone, xtime, xdate, temp, status FROM temp_log WHERE zone LIKE 'Unit%' ORDER BY Id DESC LIMIT 3
I know that the last 3 entries will contain the 3 units and I always get the last 3 entries in the table, however, I cannot seem to get the order correct. :
sometimes:
Unit03
Unit01
Unit02
or:
Unit01
Unit03
Unit02
sometimes it is the way I want it:
Unit01
Unit02
Unit03
What do I need to add to the query to get the zone names in the correct order? Or possibly a better way of doing what I want to do.
Thanks,
Troy
MYSQL multiple ORDER BY fields
in MySQL Help
Posted · Edited by Troy2000
Thanks Psycho!
That was it. Sorry for my lack of knowledge in sql query. This works fine!
Troy