On Mon, Aug 31, 2009 at 12:46:21PM -0500, Doug scratched on the wall:
> CREATE TABLE Statistic
> (
> StatID INTEGER PRIMARY KEY,
> OwningComputer TEXT NOT NULL
> );
>
> CREATE TABLE StatData
> (
> StatID INTEGER NOT NULL,
> Value INTEGER NOT NULL,
> Date INTEGER NOT NULL
> );
> I'm trying to figure out the best way to find any entries in Statistic that
> don't have any corresponding entries in StatData (ie what Statistic is
> defined, but no longer has any data attached).
Do a LEFT JOIN and then find the NULLs where there shouldn't be NULLs:
SELECT *
FROM Statistic NATURAL LEFT JOIN StatData
WHERE Data IS NULL;
-j
--
Jay A. Kreibich < J A Y @ K R E I B I.C H >
"Our opponent is an alien starship packed with atomic bombs. We have
a protractor." "I'll go home and see if I can scrounge up a ruler
and a piece of string." --from Anathem by Neal Stephenson
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users