This is a discussion on query not working properly within the PHP General forums, part of the PHP Programming Forums category; Hi everyone, I'mt trying to do the below query which itself works correctly, but when I add a order ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi everyone,
I'mt trying to do the below query which itself works correctly, but when I add a order by statement just bombs. $query = "select * from articles where ( {$now} BETWEEN startdate AND enddate) and categoryid = 1 limit 0,3"; $query = "select * from articles order by startdate asc where ( {$now} BETWEEN startdate AND enddate) and categoryid = 1 limit 0,3"; This one just doesn't work, can you tell me what I have done wrong?? Thanks |
|
|||
|
Hi Joey,
Thursday, July 26, 2007, 1:36:37 PM, you wrote: > Hi everyone, > I'mt trying to do the below query which itself works correctly, but when I > add a order by statement just bombs. > $query = "select * from articles where ( {$now} BETWEEN startdate > AND enddate) and categoryid = 1 limit 0,3"; > $query = "select * from articles order by startdate asc where ( > {$now} BETWEEN startdate AND enddate) and categoryid = 1 limit 0,3"; > This one just doesn't work, can you tell me what I have done wrong?? Err.. ORDER BY comes at the END of your query, not the start. SELECT * FROM blah WHERE blahblah ORDER BY y ASC LIMIT x,y Cheers, Rich -- Zend Certified Engineer http://www.corephp.co.uk "Never trust a computer you can't throw out of a window" |