MySQL getting inserted ID lazarus / 16-Databases ---------------------------------------------------------------------- motaz · 2016-02-04 08:41 I'm trying to run query like this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i insert into atable ..... ;SELECT LAST_INSERT_ID(); When I run Open or Execute for that query I get this error: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  : Error executing query: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT LAST_INSERT_ID() as id' at line 4 How can I get last inserted ID for MySQL I'm using Lazarus 1.4.4 ---------------------------------------------------------------------- JZS · 2016-02-04 08:53 Hi Motaz, You can use MySQLConnection and call GetInsertID after executing Insert Query: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ...MySQL56Connection1.GetInsertID;... ---------------------------------------------------------------------- motaz · 2016-02-04 10:04 it worked just fine, Thank you