1

I am searching for a solution to add multiple values into a table where one of these values is coming from another table. Something like this:

INSERT INTO Table2 (Telnumber, adress) VALUES ('12324567890',
SELECT applicatieID from Applicatie WHERE Naam = 'piet' )

So 1 of the values has to come from another table and the other values I have to insert myself. The above query won't work. Does anybody have a solution?

2 Answers 2

3

Use insert . . . select:

INSERT INTO Table2 (Telnumber, adress)
    SELECT '12324567890', applicatieID
    from Applicatie
    WHERE Naam = 'piet';

insert . . . select does almost everything that insert . . . values does, plus more.

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

Comments

1

You can use INSERT INTO with your SELECT request :

INSERT INTO Table2 (Telnumber, adress) 
SELECT '1234567890', applicatieID 
FROM Applicatie 
WHERE Naam = 'piet'

Comments

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.