1--sql insert quest example
2INSERT INTO table_name (column1, column2, column3, ...)
3VALUES (value1, value2, value3, ...);
1INSERT INTO table_name (a, b) VALUES (val1, val2);
2INSERT INTO table_name (a, b) VALUES (val1, val2), (val3, val4); -- 2 rows
3
4-- From a query:
5INSERT INTO table_name (a, b)
6 SELECT val1 AS a, val2 AS b
7 FROM source_table s
8 WHERE s.val1 >= 10;
1/*No List parameters */
2INSERT INTO table_name
3
4VALUES (value1, value2, value3, ...);
1Add new rows to a table.
2Example: Adds a new vehicle.
3INSERT INTO cars (make, model, mileage, year)
4VALUES ('Audi', 'A3', 30000, 2016);
1It is possible to write the INSERT INTO statement in two ways:
2
31. Specify both the column names and the values to be inserted:
4INSERT INTO table_name (column1, column2, column3, ...)
5VALUES (value1, value2, value3, ...);
6
72. If you are adding values for all the columns of the table, you do not need to specify the column names in the SQL query. However, make sure the order of the values is in the same order as the columns in the table. Here, the INSERT INTO syntax would be as follows:
8INSERT INTO table_name
9VALUES (value1, value2, value3, ...);
1INSERT INTO users (first_name, last_name, address, email)
2VALUES (‘Tester’, ‘Jester’, ‘123 Fake Street, Sheffield, United
3Kingdom’, ‘test@lukeharrison.dev’);