Results 1 to 6 of 6
Mar 18, 2011, 11:34 #1
- Join Date
- Sep 2008
- 0 Post(s)
- 0 Thread(s)
single query to insert and get last_id or get existing id?
I thought I read a nifty solution from rudy a couple of weeks ago but I can't seem to find it.
I want to insert a new record to a table and get the last_insert_id but in the same query, I want to get the existing id if the recrd was already there.
here is how I currently insert and get last_insert_id
and here is how I get last_insert_id
all done in a transaction.
I want to get the file_id for this file_name, when there is a new record created or it already exists.
Can it be done in one query?