Reputation: 89169
I am trying to create a SQL query where I need to insert a new sets of records based but 1 column is needed from required table.
E.g.,
TABLE_1
=======
ID,
A,
B
TABLE2
======
ID,
C,
D
Each ID
are identical ID column.
I have a query of this format:
INSERT INTO TABLE_1 (ID, A, B) VALUES (???, "Yes", "What")
WHERE ID IN (SELECT ID FROM TABLE_2 WHERE ID > 10)
This, clearly doesn't work.
My question: how do I add the ID
value from Table 2 into Table 1 and make it runnable? This is a query that must run on Oracle 11g.
Upvotes: 0
Views: 1641
Reputation: 69440
Try this query:
INSERT INTO MyTable(ID, A, B)
SELECT ID,'YES','What' FROM TABLE_2 WHERE ID > 10
Upvotes: 3