last row in the table
| From: | Andrey Hristov | Date: | Fri, 21 Dec 2001 15:18:51 +0000 |
| Subject: | last row in the table | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-78472@lists.php.net to get a copy of this message | ||
Ususally when someone needs to select last row in a table (s)he do:
select * from some_table order by some_field desc limit 1;
but there is another possible solution for mysql :
<?
mysql_free_result(mysql_query('select @a:=max(member_id) from memberInfo'));
$res=mysql_query('select * from memberInfo where member_id=@a;');
$brr=mysql_fetch_array($res);
mysql_free_result($res);
var_dump($brr);
?>
More info here : http://www.mysql.com/doc/V/a/Variables.html
Regards,
Andrey Hristov