1

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

2 Answers 2

4

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).

Sign up to request clarification or add additional context in comments.

Comments

0

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'

1 Comment

Way too complicated. A simple INSERT with multiple rows will do.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.