Wart_Hog
09-03-2005, 05:27 PM
Hi,
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)
http://www.blackmarketculture.com/events/on_display.php
SELECT *
FROM galleries g,shows s
WHERE
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'
Query: ordered by datetime (no join)
http://www.blackmarketculture.com/events/on_display_no_join.php
SELECT *
FROM shows
WHERE
UNIX_TIMESTAMP('".$today."') >= UNIX_TIMESTAMP(date2) AND
UNIX_TIMESTAMP('".$today."') <= UNIX_TIMESTAMP(close)
ORDER BY 'date2'
Thank you for your time,
-Mike
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)
http://www.blackmarketculture.com/events/on_display.php
SELECT *
FROM galleries g,shows s
WHERE
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'
Query: ordered by datetime (no join)
http://www.blackmarketculture.com/events/on_display_no_join.php
SELECT *
FROM shows
WHERE
UNIX_TIMESTAMP('".$today."') >= UNIX_TIMESTAMP(date2) AND
UNIX_TIMESTAMP('".$today."') <= UNIX_TIMESTAMP(close)
ORDER BY 'date2'
Thank you for your time,
-Mike