stubarny Posted March 21, 2007 Share Posted March 21, 2007 Hi everyone, I'm looking to change the following code so that it sorts by a column number rather than a column name: select * from ( SELECT title, body, post_timestamp FROM ads_live WHERE MATCH(title, body) AGAINST ('$_GET[q]' IN BOOLEAN MODE) ORDER BY post_timestamp DESC LIMIT 1,2) as a order by a.a.post_timestamp ASC So I've tried the following which doesn't work: select * from ( SELECT title, body, post_timestamp FROM ads_live WHERE MATCH(title, body) AGAINST ('$_GET[q]' IN BOOLEAN MODE) ORDER BY 2 DESC LIMIT 1,2) as a order by a.a.2 ASC In testing i've found that it's the "a.a.2" part that is failing. Thanks for any help you can give! Stu Link to comment https://forums.phpfreaks.com/topic/43743-solved-order-by-column-number-problem/ Share on other sites More sharing options...
Barand Posted March 22, 2007 Share Posted March 22, 2007 Why the subquery? SELECT title, body, post_timestamp FROM ads_live WHERE MATCH(title, body) AGAINST ('$_GET[q]' IN BOOLEAN MODE) ORDER BY 3 DESC LIMIT 1,2 Link to comment https://forums.phpfreaks.com/topic/43743-solved-order-by-column-number-problem/#findComment-212454 Share on other sites More sharing options...
stubarny Posted March 22, 2007 Author Share Posted March 22, 2007 ok thanks, i was adapting some other code hence it being overly complicated. Stu Link to comment https://forums.phpfreaks.com/topic/43743-solved-order-by-column-number-problem/#findComment-212562 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.