Suppose i have one table [tblemployee]
i have one department = 21
i have one status = 3
i have value = 1,2,3,4
i have member = 21,22,32,45
i want one single query which will insert 4 record like
21 3 1 21
21 3 2 22
21 3 3 32
21 3 4 45
which mean department and status will be开发者_开发百科 same for all row please help me
Something like this?
INSERT INTO tblemployee(department, status, value, member)
VALUES(21, 3, 1, 21),(21, 3, 2, 22),(21, 3, 3, 32),(21, 3, 4, 45);
You can find more information for the INSERT syntax in the documentation (look for multirow).
Try something like this for your query
INSERT INTO MyTable (ID, Name)
SELECT 123, 'Timmy'
UNION ALL
SELECT 124, 'Jonny'
UNION ALL
SELECT 125, 'Sally'
精彩评论