Here is an insert statement.
insert into tableA (c1, c2, c3) values ( v1, v2, v3)
It happens v1 and v2 are the same value as (select x from tableB where x='y')
I want to avoid add select
twice in the insert query. Is there a way like insert into tableA (c1, c2, c3) values ( (select x from tableB where x='y') a, a, v3)
?
This is not a hard question but it’s not a duplicate either. The difference is so obvious. Sigh. Editor. Learn to read.
Advertisement
Answer
You seem to want insert . . . select
:
insert into tableA (c1, c2, c3) select x, x, 'testvalue' from tableB where x = 'y';