I have the following MySQL database:
|deal_name|price|shop|expiration_date
- - - - - - - - - -
|sale1|110|shop1|03-30-2012 00:00:00
|sale2|120|shop1|03-29-2012 00:00:00
|sale3|130|shop2|03-12-2012 00:00:00
|sale4|140|shop2|03-29-2012 00:00:00
|sale5|150|shop3|03-30-2012 12:00:00
|sale6|160|shop3|03-30-2012 00:00:00
On my homepage I want to show 1 deal from each shop ordered by the price and the deal cannot been expired.
Example homepage:
sale1
sale5
I have now this:
SELECT *
FROM deals
WHERE DATE_FORMAT(expiration_date,'%Y-%m-%d') >=CURDATE() $cat
ORDER BY deal_id ASC
How can I do it? What do I have to add? Thank you!
If you don’t care about which deal you get then you can try adding MAX or MIN to the price and then grouping
Untested, but should get you started.