mysql insert into table code example

Example 1: fk in insert mysql

INSERT INTO joke(joke_text, joke_date, author_id)
VALUES (‘Humpty Dumpty had a great fall.,18990313, 
        (SELECT id FROM author WHERE author_name = ‘Famous Anthony’));

Example 2: mySql insert row

INSERT INTO `table_name`(column_1,column_2,...) VALUES (value_1,value_2,...);

Example 3: Insert mysql

#Some columns or all 
INSERT INTO table_name (column1, column2, column3, ...)
VALUES (value1, value2, value3, ...);
#All columns
INSERT INTO table_name
VALUES (value1, value2, value3, ...);

Example 4: insert mysql

INSERT INTO tbl_name (a,b,c) 
    VALUES(1,2,3), (4,5,6), (7,8,9);

Example 5: insert into mysql

INSERT INTO "table_name" ("column1", "column2", "column3", ...)
VALUES ('value1', "value2", 'value3', ...);

Tags:

Sql Example