John
John

Reputation: 7880

last inserted row in mysql

I executed a query which will insert an image link and username into a table:

INSERT into pictures set src = 'image link', username = 'acc'

I want to display that image after the query is executed (from table), or to get ID (I tried mysql_insert_id(), but what if 3 or more users will execute the query at the same time, which id will I get?

Thanks.

Upvotes: 5

Views: 1101

Answers (1)

Nanne
Nanne

Reputation: 64409

It gets the last ID from your database session, so if other users insert, that does not matter :D.

As long as your session does not do other insert (thats quite unlikely in mosts systems) in between you're fine

Upvotes: 11

Related Questions