0

From this tutorial i found a way to get the last inserted id of a specific table (with pdo).In the example

$result = $db->exec("INSERT INTO table(firstname, lastname) VAULES('John', 'Doe')");
$insertId = $db->lastInsertId();

he made a query before getting the id i would to make something like this but i want to get the id oft he last inserted entry first before doing any query.How should i tell the code that it should check the last inserted id from this table. Any idea is appreciated.

Update

I want to get the last inserted id of a specific table not only the last inserted id of the database

Community
  • 1
  • 1
Pekka
  • 1,075
  • 2
  • 10
  • 17
  • possible duplicate of [how to get last inserted id from table mysql](http://stackoverflow.com/questions/20891875/how-to-get-last-inserted-id-from-table-mysql) – Naruto Mar 20 '15 at 08:35

1 Answers1

0

Try this...

its return last inserted id before any query run.

select * from yourtable order by id desc limit 0,1
Deenadhayalan Manoharan
  • 5,436
  • 14
  • 30
  • 50