[thelist] [MySQL] return values from query

shawn allen shawn at alterior.net
Thu Feb 13 18:03:01 CST 2003


quoth Paul Bennett:
> Is there a way to return a field value from an insert query? Instead
> of (1) inserting a new record and then (2) a select to get the match
> of the new record and get the row id from the query (auto increment,
> primary key), is there a way I can INSERT the new record and get mysql
> to tell me the row_id value without querying a second time?

SELECT LAST_INSERT_ID() FROM foo;
- or -
php's mysql_insert_id()

--
shawn allen
  mailto://shawn@alterior.net
  phone://415.577.3961
  http://alterior.net
  aim://shawnpallen




More information about the thelist mailing list