Table: FirstNames
NAME
Tom
Joe
Peter
Table: FullNames
FULL_NAME:
Tom Petty.
Joe Satriani.
Peter Griffin.
Sarah Connor.
I would like to run a query:
select *
from FullNames where FULL_NAME like '%' || (select NAME from FirstNames) || '%'
It yields:
ORA-01427: single-row subquery returns more than one row
which seems correct. Is there a way to do that in Oracle?
You could use JOIN
:
SELECT *
FROM FullNames f
JOIN FirstNames g
ON f.FULL_NAME LIKE '%' || g.NAME || '%';
You can use exists
:
select f.*
from FullNames f
where exists (select 1
from firstnames fn
where f.FULL_NAME like '%' || fn.NAME || '%'
);
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