Re: Missing table entries
Posted in 1994
> Does anyone know of a way WITHIN sql for identifying missing entries in
a
> table? I have a master table which contains a unique (indexed) code
> field.This code is also used in the detail table. Each code should have
> *atleast* one entry in the detail table, but it may have more than
one. > Howdo I find those codes which have *no* entry in the detail
table? > I can see the missing rows if I do something like:
> > select table1.code, > table2.code
> from table1, outer table2 > wheretable1.code=table2.code
> > but I have to search the output to find the gaps. The other approach I
> haveused is to UNLOAD the code from each table to a file and use the
UNIX
> command comm to find the missing codes. > > Does anyone have a better
approach?
select code
from table1
where not exists (select 1 from table2
where table1.code = table2.code)
-Andy-
akent@cix.compulink.co.uk (Andy Kent)
-------------------------------------