how to insert multiple entries in mysql table code example

Example 1: insert data into multiple tables mysql

BEGIN;
INSERT INTO users (username, password)
  VALUES('test', 'test');
INSERT INTO profiles (userid, bio, homepage) 
  VALUES(LAST_INSERT_ID(),'Hello world!', 'http://www.stackoverflow.com');
COMMIT;

Example 2: insert multiple items in mysql

#Assuming that there is a database called MyDatabase
#The following adds items to a table called TableName with columns No., Age, and class
use MyDatabase;
insert into TableName(No., Name, Age, Class)
values(1, "VinCoD", 21, "4E");

Tags:

Sql Example