Jump to content

[SOLVED] ORDER BY 'column number' problem


stubarny

Recommended Posts

 

 

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.