Jeff Weisberg on Wed, 29 May 2002 14:10:40 -0400


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] need SQL help


| not exactly sure if this is on topic, but I'm having
| some trouble with sorting, it's basically for a search
| engine for a website that sells classified ad space to
| sell homes, etc.  in short, people pay more for
| featured ads, so they are supposed to show up at the
| top of the search results, then amongst the featured
| ads, the ones where people have uploaded images show
| up first.  after the featured ad's have been
| displayed, come the non featured ads where the images
| show up first, and any non featured ad with no images
| show up last.  after all that sorting has taken place,
| the ad's are further sorted where the newest ones show
| up first.  I have the primary key's set on
| auto_increment, so the higher the primary key value is
| the newer the ad is.


If I followed that correctly, you want something like:

... ORDER BY f IS NULL, i desc, aid desc;

(or equivalently SELECT ... featured.res IS NULL AS f, ...)


Note, I don't have a mysql server, but this works in postgres.


	--jeff


______________________________________________________________________
Philadelphia Linux Users Group       -      http://www.phillylinux.org
Announcements-http://lists.phillylinux.org/mail/listinfo/plug-announce
General Discussion  -  http://lists.phillylinux.org/mail/listinfo/plug