I have two tables with 1-n relationship. One of them is auto services table and the other one has their specifications like;
ID ServiceId Name --------------------------- 1 FJ12 Fletcher Jones 2 HS35 Hardy's 3 YK65 Yorker SpecialityID ServiceID Name --------------------------------- 1 FJ12 AUTH 2 FJ12 PRIV 3 FJ12 GRS 4 HS35 PRIV 5 HS35 AUTH 6 HS35 CRS 7 YK65 PRIV 8 HS35 GRS I tried with some left outer join queries and where clauses but I couldn't handle. How can I get all auto services from first table which doesn't have 'AUTH' specification in second table ? (second table is first table's sub table)
WHERE NOT EXISTSwith a correlated subquery.WHERE NOT EXISTS, as Dan said, or aLEFT JOINseem to be the right solutions). Thanks.