Re: Need help in Query -
- From: "Arnie Rowland" <arnie@xxxxxxxx>
- Date: Mon, 19 Jun 2006 16:32:30 -0700
Try this query:
SELECT
a.ContractNo
, a.SerialNo
, a.JobNo
, a.PNo
FROM TableA a
LEFT JOIN TableB b
ON ( a.ContractNo = b.ContractNo
AND a.SerialNo = b.SerialNo
AND a.JobNo = b.JobNo
AND a.PNo = b.PNo
)
WHERE b.ContractNo IS NULL
This will locate rows in TableA without a counterpart in TableB. Change it to a RIGHT JOIN and WHERE a.ContractNo IS NULL to find any rows that are in TableB without counterparts in TableA.
And, stay tuned, you may get a better offer.
--
Arnie Rowland, YACE*
"To be successful, your heart must accompany your knowledge."
*Yet Another Certification Exam
"Me" <Me@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:F106867F-EB47-498A-B771-CAF3321D5171@xxxxxxxxxxxxxxxx
I have two tables each with concatenated key - ContractNo, SerialNo, JobNo, PNo
I would like to find out missing records in the other table, something like
select ContractNo, SerialNo, JobNo, PNo from table a
where not exists ( ContractNo, SerialNo, JobNo, PNo from table b)
when I do the query with exists in it, it shows me matching records ( I
think so as most of the recs are matching, so I can't say for sure)
however, when I change it to not exists, it doesn't .
Thank you,
-Me
- Prev by Date: Re: distinct with all the columns
- Next by Date: Re: date format
- Previous by thread: Re: distinct with all the columns
- Next by thread: Re: date format
- Index(es):
Relevant Pages
|
|