Php – SQL selecting records with dates before today

MySQLPHPsql

I have a mysql DB with tables, of which in the one table I have a date type field, I want the most recently passed date – so I want it to order by dates descending, but only take records from before today, and then take only the top most one using the LIMIT function, and also there is the addition of the WHERE clause being that the offer must be for the selected city.

$result = mysql_query("
SELECT * FROM offers 
WHERE city = ".$_SESSION["city"]." 
ORDER BY exp_date DESC 
LIMIT 0, 1");   

Best Answer

ADD another condition to where clause

$result = mysql_query("
SELECT * FROM offers 
WHERE city = ".$_SESSION["city"]."  and Date < CURRENT_DATE()
ORDER BY exp_date DESC 
LIMIT 1");