i need to join subqueries in oracle. This does not work i get a syntax error for the join operation
select s1.key, s1.value, s2.value
from ((select key, value
from tbl
where id = 1) as s1
join
(select key, value
from tbl
where id = 2) as s2
on s1.contract = s2.contract);
You should select the field you are joining on (contract
) in the inline views:
SELECT s1.key, s1.value, s2.value
FROM (
SELECT contract, key, value
FROM tbl
WHERE id = 1
) as s1
JOIN (
SELECT contract, key, value
FROM tbl
WHERE id = 2
) as s2
ON s1.contract = s2.contract
You had one too many sets of Parenthesis.
SELECT
s1.key,
s1.value,
s2.value
FROM (SELECT
key,
value
FROM tbl
WHERE id = 1) AS s1
JOIN (SELECT
key,
value
FROM tbl
WHERE id = 2) AS s2
ON s1.contract = s2.contract;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With