Relm
Relm

Reputation: 8262

SELECT FROM table WHERE lastupdated = most recently updated

How do i select from table the most recently updated row. My syntax seems to be wrong.

<?php 
require_once 'db_conx.php';
$Result = mysql_query("SELECT * FROM  'table' WHERE lastupdated('timestamp') = CURDATE()")      or die (mysql_error());
while($row = mysql_fetch_array($Result))
{
echo $row['name'] . "" .$row['phoneno'];
}
mysql_close($con);
?>

Upvotes: 0

Views: 927

Answers (2)

Sumit Bijvani
Sumit Bijvani

Reputation: 8179

Try this..

SELECT * FROM  'table' ORDER BY lastupdated DESC LIMIT 1

Upvotes: 0

Sashi Kant
Sashi Kant

Reputation: 13465

If you need the latest record which was last updated then you can Try this::

SELECT * FROM  'table' order by lastupdated desc limit 1

Upvotes: 2

Related Questions