php - How to fetch the row from MySQL having latest date -


i have table "poem" fields "dated","content" etc.

i want content of recent dated field.

$sql="select content, max(dated) latestdate poem"; 

this not working.

if want 1 row, use order by , limit:

select p.* poem p order dated desc limit 1; 

if want rows recent date:

select p.* poem p p.dated = (select max(dated) poem); 

Popular posts from this blog