Search
 
SCRIPT & CODE EXAMPLE
 

SQL

mysql id of inserted row

-- For mysql
INSERT INTO table_name (col1, col2,...) VALUES ('val1', 'val2'...);
SELECT LAST_INSERT_ID();
Comment

ring MySQL get the inserted row id

MySQL_Insert_ID() ---> Inserted row id as number
Comment

ring MySQL get the inserted row id

con = mysql_init()
see "connect to database" + nl
mysql_connect(con,"localhost","root","root","mahdb")
see "drop table" + nl
mysql_query(con, "DROP TABLE IF EXISTS Customers")
see "create table" + nl
mysql_query(con, "CREATE TABLE Customers(Id INT PRIMARY KEY AUTO_INCREMENT, Name TEXT)")
see "insert record" + nl
mysql_query(con, "INSERT INTO Customers(Name) VALUES('Mahmoud')")
see "insert record" + nl
mysql_query(con, "INSERT INTO Customers(Name) VALUES('Samir')")
see "insert record" + nl
mysql_query(con, "INSERT INTO Customers(Name) VALUES('Fayed')")
see "insert record" + nl
mysql_query(con, "INSERT INTO Customers(Name) VALUES('Test 2015')")

see "inserted row id : " + mysql_insert_id(con) + nl
see "close database" + nl
mysql_close(con)
Comment

PREVIOUS NEXT
Code Example
Sql :: mysql offset from bottom 
Sql :: Update All tables COLLATE DATABASE_DEFAULT 
Sql :: sql how to display two atributes as one in sql 
Sql :: enter postgres shell o localhost 
Sql :: update or delete on table "model" violates foreign key constraint 
Sql :: C# check if mysql query modified rows 
Sql :: ring get columns count in the query result using the odbc_colcount() 
Sql :: simple plsql program run in oracle sql developer but got the error 
Sql :: play framework connection via windows sql server 
Sql :: get all employees if name ends with in sql 
Sql :: FILENAME /usr/bin/mysql does not exists. Make sure correct path is set in /etc/dump admin/settings.conf. 
Sql :: fill up postgres db 
Sql :: current month mysql query 
Sql :: mysql db dump restore max file size issue 
Sql :: VYSTUPNI PARAMETR ULOZENE PROCEDURY SQL 
Sql :: classement rang mysql 7 
Sql :: what is logical database schema 
Sql :: export partttion and import in oracle 
Sql :: oracle grant create job 
Sql :: Downloading snowsql for Linux 
Sql :: does laravel validate sql 
Sql :: Mysql select all where count more than" 
Sql :: date functions 
Sql :: mysql datenbank anzahl anzeigen 
Sql :: mysql master slave setup with keepalived 
Sql :: cast find duration in sql 
Sql :: uninstall mysql centos 7 
Sql :: sql alchemy escape ; in insert statement 
Sql :: datatype for phone number in sql 
Sql :: How to query data in many to many relationship in flask sql alchemy 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =