Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Explain Subsqueries
I was able to get this query to work but I don’t completely understand
how it works. I used a furniture company as an example. I wanted to find
everyone who had a FASTENER but did not have a CHAIR, LAMP or TABLE. Can
someone explain how this works and if its the best way to return my
answer
SELECT ACCT_NO_FURNITURE_INFO, PHONE_NO_CUST_INFO FROM FURNITURE_INFO A, CUST_INFO WHERE ACCT_NO_CUST_INFO = A.ACCT_NO_FURNITURE_INFO AND STYLE_FURNITURE_INFO = ‘FASTENER’ AND CUST_STATUS_FURNITURE_INFO = ‘ACTIVE’ AND NOT EXISTS (SELECT 1 FROM FURNITURE _INFO B WHERE A.ACCT_NO_FURNITURE_INFO = B.ACCT_NO_FURNITURE_INFO AND STYLE_FUNITURE_INFO IN (‘CHAIR’,’LAMP’,’TABLE’)) Received on Fri Oct 23 1998 - 18:45:35 CDT