Alastair,

SELECT codecolumn FROM lookuptable +
WHERE codecolumn NOT IN +
(SELECT codecolumn FROM ForeignKeyTable)

Bill



On Mon, 8 Sep 2003 23:02:27 +0100, Alastair Burr wrote:

>Hello everyone,

>I'm trying to find what codes from a look-up table are not currently in use:

>I have a data table that has, amongst other columns, a text column with a
>(variable) number of 2 character codes separated by a comma, viz:
>aa,ab,ac,ba,bb,bc...

>The look-up table has code column with a row for each code and a 
column with
>a description.

>I can find which codes are in use easily enough and I thought that the
>missing ones could be found by "reversing" the logic but it doesn't work:

>Briefly, SELECT... WHERE ... CONTAINS tell me the ones in use but 
SELECT...
>WHERE ... NOT CONTAINS gives me everything.

>I can think of a way to do it using a temp table but I wondered if there was
>an SQL way to find the unused items? Anybody got any ideas?

>Thanks in advance,
>Regards,
>Alastair.

>----------------------------------
>A D B Burr,
>St. Albans, UK.
>----------------------------------
>[EMAIL PROTECTED]
>----------------------------------

Reply via email to