sql - converting a sub query into self join -
i have query in want find other authors each title in author mr.x
the query wrote is:
select distinct (author_name) authors table1 title = (select title table1 (author_name) = 'x'); i got error: more 1 row returned subquery used expression
i think avoid error should use self join i'm not able figure out how it.
your subquery returning more 1 record , in such case can't use = operator rather should use in operator check against multiple values below
where title in (select title table1 (author_name) = 'x') so, query should like
select distinct (author_name) authors table1 title in (select title table1 (author_name) = 'x'); to change join instead
select distinct (t1.author_name) authors table1 t1 join table1 t2 on t1.title = t2.title
Comments
Post a Comment