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 multiple rows
, for those wishing to be able to refer to the technique conceptually. Ref: dev.mysql.com/doc/refman/5.5/en/insert.html – Immortelleinsert set col1='val1', col2='val2 (?) col1='val3', col2=val2'
in/for mysql ? I mean inserting multiple rows with mysql-specificinsert set
syntax; is it possible? – Popularityinsert into profiles (name, description) select first, 'Auto-generated' from users
You seem to be confusing insert and update statement, which are different beasts. – Immortelleinsert
in theupdate
fashion withset
keyword rather thanvalues
. It is very MySQL specific non-standard SQL statement. – Popularityinsert ... 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 – Immortelle