On Wednesday 18 June 2003 13:59, Carter, Scott wrote:
> This may not be the correct solution exactly, but what I do to ensure that
> I get the correct ID back is the following:
>
> I know what I just inserted, therefore I can use this information in a
> WHERE clause to ensure retrieving the correct ID.
>
>       Example:      INSERT name='scott', age=20 into myTable WHERE
> ........;
>               then    SELECT id FROM myTable WHERE name='scott' AND
> age=20;
>

That works IFF name='scott' and age=20 is GUARANTEED to be unique.
It's much better to get the last_insert_id() from a query.  

-- 
Eric Calvert
kyconnection.com, inc.

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to