order by datetime / join
I have recently learned how to join tables in queries with mysql.
But, like anything new, I am running into some problems.
I would like the results to be sorted by datetime, but for some reason they are sorted in random order. I have listed the queries that I am using below with a link to a page where you can see the results of each query.
s.date2 = (datetime) opening date
s.close = (datetime) closing date
Query: random order (joined)
Query: ordered by datetime (no join)
FROM galleries g,shows s
g.gallery_id = s.gallery_id AND
UNIX_TIMESTAMP('".$today."') >= UNIX_TIMESTAMP(s.date2) AND
UNIX_TIMESTAMP('".$today."') <= UNIX_TIMESTAMP(s.close)
ORDER BY 's.date2'
Thank you for your time,
UNIX_TIMESTAMP('".$today."') >= UNIX_TIMESTAMP(date2) AND
UNIX_TIMESTAMP('".$today."') <= UNIX_TIMESTAMP(close)
ORDER BY 'date2'
Hi Mike, try removing the quotes around your date fields in your ORDER BY statement.
Yep that was the culprit...
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)