I misread what you wanted to do.  Now that I've re-read your post, I realize
that the proper statement for what you want to do uses NOT IN rather than
IN.  

So...
DELETE FROM files
WHERE filestamp NOT IN
(SELECT filestamp FROM snapshot);

Zack

-----Original Message-----
From: Jarrett, Zachary 
Sent: Wednesday, June 07, 2006 12:44 PM
To: '[email protected]'
Cc: '[EMAIL PROTECTED]'
Subject: RE: [sqlite] OT: SQL Help

If filestamp is your identifier, the following statement will do the job...

DELETE FROM files
WHERE filestamp IN
(SELECT filestamp FROM snapshot);


I recommend that you check out some tutorials online and at least learn the
basics.  There's no reason to continue to suck at SQL.  A good place to
start is:
http://www.w3schools.com/sql/default.asp

A google search of 'sql tutorial' will turn up options than you can shake a
stick at.

Zack


-----Original Message-----
From: Craig Morrison [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 07, 2006 11:44 AM
To: [email protected]
Subject: [sqlite] OT: SQL Help


With all the other discussions going on with more important matters please
excuse this brief interruption..

I have two tables that are created thusly:

CREATE TABLE files (filehash VARCHAR(48) UNIQUE, filestamp INTEGER, filename
VARCHAR(2048)); CREATE TABLE snapshot (filehash VARCHAR(48) UNIQUE,
filestamp INTEGER, filename VARCHAR(2048));

I suck at SQL, so I plead for your advice..

I want to be able to delete all rows from 'files' that do *not* exist in
'snapshot'. My efforts to date have done nothing but leave me with less
hair.

Thanks.

--
Craig Morrison
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
http://pse.2cah.com
   Controlling pseudoephedrine purchases.

http://www.mtsprofessional.com/
   A Win32 email server that works for You.

Reply via email to