SQL Insert Multiple Rows code example

Example 1: sql count duplicate rows

SELECT _column, COUNT(*) 
FROM _table
GROUP BY _column
HAVING COUNT(*) > 1

Example 2: sql server insert multiple rows

INSERT INTO table_name (column_list)
VALUES
    (value_list_1),
    (value_list_2),
    ...
    (value_list_n);

Example 3: SQL Insert Multiple Rows

INSERT INTO StudentTable

( Rollo, Name, Class, Contact )

VALUES ( '1', 'Jonny', '10th', '9856245'  ),

( '2', 'Ronny', '12th', '5421545'  );

Example 4: insert multiple rows in sql.

INSERT INTO table (col1, col2, col3)
VALUES
	(row1_val1, row1_val2, row1_val3),
	(row2_val1, row2_val2, row2_val3),
	(row3_val1, row3_val2, row3_val3);

Example 5: how to insert multiple records at once in sql acess

INSERT INTO target_table ( column_name1, column_name2 )
SELECT column_name1, column_name2
FROM (SELECT tableNameColumn AS column_name1, tableNameColumn2 FROM tableName, tableName2
WHERE tableNameColumn = 3 AND tableNameColumn2 = 1 
UNION ALL
SELECT tableNameColumn AS column_name1, tableNameColumn2 FROM tableName, tableName2
WHERE tableNameColumn = 3 AND tableNameColumn2 = 1) AS TMP

example:
INSERT INTO ProgKnowledge ( UserID, ProgramID )
SELECT UserID, ProgramID
FROM (SELECT Users.ID AS UserID, Programs.ProgramID FROM Users, Programs
WHERE Programs.ProgramID = 3 AND Users.ID = 1
UNION ALL
SELECT Users.ID AS UserID, Programs.ProgramID FROM Users, Programs
WHERE Programs.ProgramID = 4 AND Users.ID = 1)  AS add;

Example 6: insert multiple values into one column sql

INSERT INTO Data ( Col1 ) VALUES
('Hello'),
('World');

Tags:

Sql Example