On Oct 04, 2006, at 5:45 PM, Toby Rush wrote:

Okay, it's taken me about an hour to even be able to form this into a comprehendible question...

In my REALSQL database, I have two tables, tPersons and tHats.
- The tPersons table has one field: "idNumber" and "personName".
- The tHats table has three fields: "idNumber", "hatColor" and "ownerIDNumber". The "ownerIDNumber" field references tPersons.idNumber; its purpose is to indicate which tPerson owns that particular tHat.

I want to run a query for tPersons that do not own any tHats, and I can't figure out a way to do it using my noobie SQL knowledge.

I can get the inverse, or complement, of what I want by using this statement:

SELECT tPersons.* FROM tPersons,tHats WHERE tHats.ownerIDNumber=tPersons.idNumber

How can I do the opposite of that? In other words, how can I get a recordSet containing the rows that the above statement does not return? Thanks in advance...

OK... you want all the data from tPersons where their id is NOT IN the set of people that have a tHat

the set of people who have tHats is

        select ownerIDNumber from tHats

so those that have no tHat is

select * from tPersons where idNumber not in ( select ownerIDNumber from tHats )



_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to