I want to get data out of a single table, restricted to where an ID field exists on another table. The ID may exist more than once on the second table, so doing a join would cause me to get duplicate values from the first table. However, it's also possible that there would be records on the first table where the data I retrieve is identical, and I would want each of these to be retrieved - so I can't use Distinct.
I can do it easily enough with this:
... but I worry that this would be very inefficient.Code:Select A.Field1 , A.Field2 , A.Etc From tblAgent A Where Exists (Select 1 from tblTransaction T where T.FirmID = A.ParentFirmID)
Is there a neater way to do it? A particular type of join, perhaps?
Thanks...




Reply With Quote