I have multiple set of data to insert at once, say 4 rows. My table has three columns: Person
, Id
and Office
.
INSERT INTO MyTable VALUES ("John", 123, "Lloyds Office");
INSERT INTO MyTable VALUES ("Jane", 124, "Lloyds Office");
INSERT INTO MyTable VALUES ("Billy", 125, "London Office");
INSERT INTO MyTable VALUES ("Miranda", 126, "Bristol Office");
Can I insert all 4 rows in a single SQL statement?
insert into profiles (name, description) select first, 'Auto-generated' from users
You seem to be confusing insert and update statement, which are different beasts.insert ... select
syntax, it'll get you everything you need and is as flexible as can be wished for. dev.mysql.com/doc/refman/5.5/en/insert.html