Forum Moderators: coopster

Message Too Old, No Replies

Sorting my listing from mysql

order by or group by

         

whizzy

6:22 am on Jul 13, 2003 (gmt 0)

10+ Year Member



I'm listing out products from my database and each product is stored with a default picture called nopic.jpg and a date of change.

I want to list out products so the products with picure comes first and at the same time the products updated last should come first out of them as well.

I tried with this:

ORDER BY prod_changed desc, picname

But when a product with nopic is updated it comes first.

Any ideas...I'm stuck...

vincevincevince

7:22 am on Jul 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



does
ORDER BY prod_changed DESC GROUP BY picname DESC
work?

olwen

7:38 am on Jul 13, 2003 (gmt 0)

10+ Year Member



Try "select *,(picname="nopic.jpg) as havepic order by havepic, prod_changed desc"

whizzy

2:25 am on Jul 14, 2003 (gmt 0)

10+ Year Member



Thanks Olwen...it works now!

Just had to change yours to:

"select *,(picname<>"nopic.jpg) as havepic order by havepic, prod_changed desc"

So simple :)