INSERT INTO table1 (col1, col2, col3)
VALUES ('abc', 123, true);INSERT INTO table1 (col1, col2, col3) SET col1 = 'abc', col2 = 123, col3 = true;
Insert with return values
INSERT INTO users (first_name, last_name)
VALUES ('John', 'Doe')
RETURNING id, created_at;Insert using select query
INSERT INTO table1 (col1, col2, col3) SELECT col1, col2, col3 FROM table2 WHERE condition2
Update using select query
UPDATE table1 JOIN (SELECT * FROM table2) AS table2 SET table1.col1 = table2.xxx WHERE condition1

Leave a Reply