Philip Thompson wrote:
> For auto increment values, you don't have to specify the id. For example:
> 
> INSERT INTO t_users (f_name, l_name, e_mail, b_date, pic)
> VALUES ('$f_name', '$l_name', '$e_mail', '$b_date', null);
> 
> Then to find the latest entry:
> 
> SELECT user_id FROM t_users ORDER BY user_id DESC limit 1;

This is not the cleanest way and some databases do not actually
increment auto id fields (e.g. they could fill in the blanks from
previous deletes etc.).

Much better is to use the function in the MySQL API to get the insert id
or if you really must use SQL, just run "SELECT LAST_INSERT_ID();" which
does much the same thing.

Col

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to