We help IT Professionals succeed at work.
Get Started

Oracle - Query where no result in a table

192 Views
Last Modified: 2015-03-29
Hi

I'm trying to query all carriers where CARRIER_ID, LANE_ID and TL_RESOURCE_ID from table TL_RESOURCE_CARRIER will not show in table  TL_RESOURCE_TRLR.

In the below query, i pulls records where it does show a record in both tables.

In the attachment, you will see the 3 tables and what should be the final result for the query needed.

Thanks for your help.

SELECT DISTINCT TRC.CARRIER_ID,
  TRC.LANE_ID,
  L.NAME
FROM LANE L,
  TL_RESOURCE_CARRIER TRC,
  TL_RESOURCE_TRLR TRT
WHERE TRT.LANE_ID           = L.ID (+)
AND TRC.LANE_ID             = TRT.LANE_ID (+)
AND TRC.CARRIER_ID NOT     IN TRT.CARRIER_ID
AND TRC.TL_RESOURCE_ID NOT IN TRT.TL_RESOURCE_ID
AND TRC.LANE_ID             = L.ID
ORDER BY TRC.CARRIER_ID;

Open in new window

tl-resources-carrier-table.xlsx
Comment
Watch Question
Senior Oracle DBA
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 2 Answers and 10 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE