I need to use SELECT LAST_INSERT_ID()
function of MySQL to get the ID of last inserted row.
When I try to run this:-
mysql_query("
INSERT INTO `posts`
(`user`, `body`, `time`, `pageID`)
VALUES('pachykutty', 'testMessage', '2012-10-26 04:59:43', 1);
SELECT LAST_INSERT_ID();");
Gives me error, but When I run the two queries separately like this:-
mysql_query("
INSERT INTO `posts`
(`user`, `body`, `time`, `pageID`)
VALUES('pachykutty', 'testMessage', '2012-10-26 04:59:43', 1)");
mysql_query("SELECT LAST_INSERT_ID()");
It is OK. I fear that If two clients ran the query same time, their LAST_INSERT_ID will conflict. So I want to run the two queries together without delay. Is there any way?