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 Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.