Try something like this:

Select b.* from TableB b where not exists(select 1 from TableA a 
where a.KeyField = b.KeyField)

HTH
Woody (TMW)


-----Original Message----- 
From: Fulvio Senore 
Sent: Friday, December 20, 2013 7:15 AM 
To: [email protected] 
Subject: [firebird-support] Help with a query 

I have two tables, for example TableA and TableB.

Each row of TableA contains a foreign key to a row of TableB.
This a 1 to 1 relation, so each row of TableA is linked to one different 
row of TableB.
The foreign key field can also be NULL, in this case the TableA row is 
not connected to a TableB row.

All TableB rows depend logically on TableA rows, so all TableB rows 
should be linked by a TableA row.

I would like to check for program errors during development, so I would 
like to know if there are "orphans" TableB rows.

May somebody suggest me a good way to find the rows in TableB that are 
not connected from any row in TableA?

Thanks in advance

Fulvio Senore




------------------------------------

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Visit http://www.firebirdsql.org and click the Resources item
on the main (top) menu.  Try Knowledgebase and FAQ links !

Also search the knowledgebases at http://www.ibphoenix.com 

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Yahoo Groups Links






------------------------------------

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Visit http://www.firebirdsql.org and click the Resources item
on the main (top) menu.  Try Knowledgebase and FAQ links !

Also search the knowledgebases at http://www.ibphoenix.com 

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Yahoo Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/firebird-support/join
    (Yahoo! ID required)

<*> To change settings via email:
    [email protected] 
    [email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo Groups is subject to:
    http://info.yahoo.com/legal/us/yahoo/utos/terms/

Reply via email to