Is it possible - with some syntax adaptation - to fulfill the purpose of the following query?
insert into X (a, b) values(16, select c from Y where d = e)
Is it possible - with some syntax adaptation - to fulfill the purpose of the following query?
insert into X (a, b) values(16, select c from Y where d = e)
You can use quotation marks for such a requirement, thus creating a Subquery
.
A Subquery
is basically one query within another. When working with subquerys, we should beware of certain points, such as the case that a subquery can return more than one value, causing your sql query to generate an error (my experience is based only on databases mssql
and oracle
, so I do not know the behavior of other databases.)
Example:
insert into X (a, b) values(16, (select c from Y where d = e))
insert into X (a, b)
select 16, c from Y where d = e
You can do that too, without the word values .
You do not even have to put the word Values, just that the values are inside the select. So:
insert into X (a, b) (select "16", c from Y where d = e)