1

I would like to insert data from specific fields from one table in another table + some static values. Roughly I would like to do this:

INSERT INTO TableA(Field1, Field2, Field3) 
SELECT Field1, Field2, 'staticvalue', Field3
FROM TableB
WHERE TableB.Field6 = 'XYZ'

Any idea how can I mix both specific fields from one table and static values?

1

1 Answer 1

2

You're on the right track... you need to supply a column for the static value to be inserted into.

INSERT INTO TableA(Field1, Field2, someOtherField, Field3) 
SELECT Field1, Field2, 'staticvalue', Field3
FROM TableB
WHERE TableB.Field6 = 'XYZ'
Sign up to request clarification or add additional context in comments.

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.