Hello,I want to create a procedure or query that removes old entries from my DB. I have three tables. When deleting a row in table1, a score must descrease in table2 and possibly a row must be deleted in table3.In detail I want to do this:- delete * from ENTRIES WHERE post_datetime OLDER THEN 30DAYS AND provider <> 'local'- decrease SCORES.score WHERE SCORES.tag = ENTRIES.tag from deleted row of the last query- delete * from URLS WHERE url does not anymore exist in ENTRIES.urlMy attempt:DELETE * FROM ENTRIES WHERE datediff ('day', post_datetime, now()) > 30 AND provider <> 'local'UPDATE SCORES SET score = score-1 WHERE ( tag = ????? )DELETE * FROM URLS WHERE EXISTS (SELECT * FROM ENTRIES WHERE (URLS.url = ENTRIES.url))My problem is query2. How can I get ENTRIES.tag from the deleted rows of query1, and use it in query2?Or is there maybe a more elgant way to do what I want? Can I do all this in one single query?Thanks a lot!BMy DB tables:create table ENTRIES( "id" INTEGER IDENTITY, "tag" VARCHAR(255), "url" VARCHAR(255), "provider" VARCHAR(255), "post_datetime" DATETIME, PRIMARY KEY ("id"));create table SCORES( "tag" VARCHAR(255), "score" INTEGER, "cur_timestamp" TIMESTAMP, PRIMARY KEY ("tag"));create table URLS( "url" VARCHAR(255), "title" VARCHAR(255), "last_posted" DATETIME, PRIMARY KEY ("url")); quote: