Re: Missing table entries
Posted in 1994
From irl3b2c.att.com!bt@uunet.uu.net:
*
* 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 *at
* least* one entry in the detail table, but it may have more than one. How
* do 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
* where table1.code=table2.code
*
* but I have to search the output to find the gaps. The other approach I have
* used 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?
Try just like you stated:
SELECT code FROM table1
WHERE code NOT IN ( SELECT code FROM table2 )
Robert Minter |Data Systems Support| \\\\\\_///
Programmer, Software Development | Orange, CA | ( _ _ )
internet: rob@dssmktg.com | Tel: 714.771.0454 | (| ^ |)
bangpath: uunet.uu.net!dssmktg!rob| Fax: 714.771.3028 | \\`-'/
#include <disclaimer.h> SURF'S UP \\_/