[PHP-DB] Query for Most Recent Entry

2004-07-02 Thread Thompson, Jimi
Hi,

 

I'm trying to figure out how to write a MySQL query that will return the
highest primary key a table.  

 

Thanks,

 

Ms. Jimi Thompson, CISSP

Manager, Web Operations

Cox School of Business

Southern Methodist University

 

What kind of peace do we seek? Not a 'Pax Americana' enforced on the
world by American weapons of war. Not the peace of the grave or the
security of a slave. I am talking about genuine peace, the kind of peace
that makes life on earth worth living, the kind that enables men and
nations to grow and to hope and to build a better life for their
children-not merely peace for Americans, but peace for all men and
women; not merely peace in our time, but peace for all time. - John F.
Kennedy

 

 

 



Re: [PHP-DB] Query for Most Recent Entry

2004-07-02 Thread John W. Holmes
Thompson, Jimi wrote:
I'm trying to figure out how to write a MySQL query that will return the
highest primary key a table.  
1) Why?
2) SELECT MAX(id) FROM table
3) If you're trying to find the key of the last row inserted to an 
auto_increment column, use mysql_insert_id() or LAST_INSERT_ID() in PHP 
and MySQL, respectively.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php