mysql insert code example
Example 1: mysql insert on dupèlicate
INSERT INTO table_name(c1)
VALUES(c1)
ON DUPLICATE KEY UPDATE c1 = VALUES(c1) + 1;
Example 2: sql insert query
--sql insert quest example
INSERT INTO table_name (column1, column2, column3, ...)
VALUES (value1, value2, value3, ...);
Example 3: posgres insert
INSERT INTO films
(code, title, did, date_prod, kind)
VALUES
('T_601', 'Yojimbo', 106, '1961-06-16', 'Drama');
Example 4: fk in insert mysql
INSERT INTO joke(joke_text, joke_date, author_id)
VALUES (‘Humpty Dumpty had a great fall.’, ‘1899–03–13’,
(SELECT id FROM author WHERE author_name = ‘Famous Anthony’));
Example 5: mySql insert row
INSERT INTO `table_name`(column_1,column_2,...) VALUES (value_1,value_2,...);
Example 6: mysql insert
INSERT INTO table1 (col1, col2) VALUES (3, 'A string');
INSERT INTO table1 (col1) VALUES (3); -- col2 will be NULL if allowed
INSERT INTO table1 VALUES (3, 'A string'); -- all table1 columns
INSERT INTO table1 (col1, col2) SELECT value3, value1 FROM table2;