Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread How to return rows that do not have child records
Tue, Jun 5 2012 2:53 AMPermanent Link

Paul Coshott

Avatar

Hi All,

I know the sql syntax for returning only rows that have one or more child
records, but how do I return only those rows that do not have any child
records from another table?

Cheers,
Paul
Tue, Jun 5 2012 4:13 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Paul


Something like

select *
from Companies
JOIN C2C X ON X._Company = _Company
WHERE X._Company IS NULL


Roy Lambert [Team Elevate]
Tue, Jun 5 2012 11:18 AMPermanent Link

Robert Kaplan


"Roy Lambert" <roy@lybster.me.uk> wrote in message
news:8655B31B-E3E9-4F29-ABDB-2DF045FAC63D@news.elevatesoft.com...
> Paul
>
>
> Something like
>
> select *
> from Companies
> JOIN C2C X ON X._Company = _Company
> WHERE X._Company IS NULL
>
>
> Roy Lambert [Team Elevate]
>

You need LEFT OUTER JOIN, otherwise the JOIN will not pick up the ones that
have no match

Robert

Mon, Jun 25 2012 12:38 PMPermanent Link

Paul Waegemans

IMS bvba

Avatar

Is this what you are lokking for?

SELECT * FROM table1 WHERE field NOT IN (SELECT field FROM table2)


"Paul Coshott" wrote:

Hi All,

I know the sql syntax for returning only rows that have one or more child
records, but how do I return only those rows that do not have any child
records from another table?

Cheers,
Paul
Image