tags:

views:

17

answers:

2

I've got two tables, Feeds and Import in an SQLite DB. I'm pulling all enclosures from a list of rss feeds into the Import table; most of which are in the Feeds table as well. I'm trying to delete the records from the Feeds table where the enclosures are not in the Import table because they are no longer in the rssfeeds and they've been downloaded. Basically this is my setup:

TABLE Feeds
    id (TEXT)
    url (TEXT)
    downloaded (BIT)

TABLE Import
    id (TEXT)
    url (TEXT)

# results to delete
(SELECT id,url FROM Feeds WHERE downloaded = 1 EXCEPT SELECT id,url FROM Import)

I'm probably over thinking this and making it way more complicated than it really is.

+1  A: 
DELETE
  FROM Feeds a
 WHERE downloaded = 1
   AND NOT EXISTS (
          SELECT *
            FROM Import b
           WHERE a.id = b.id
             AND a.url = b.url )
dcp
A: 

Hello!

DELETE
  FROM Feeds
 WHERE downloaded = 1
   AND NOT EXISTS (SELECT 1 FROM Import WHERE id = Feeds.id AND url = Feeds.url)
Benoit
The -1 is not from me, but you needed that query to be correlated.
MPelletier