Ask Your Question

Delete records from one table when entered in to another in base [closed]

asked 2017-11-04 12:08:32 +0100

GarethT gravatar image

I'm pretty new to SQL in base, I've got a few queries set up now with a little help (thanks JohnSUN) which is great. I'm now exploring and have successfully used the DELETE FROM command for removing multiple entries from a table but would like to go a little further.

Rather than individually deleting rows by using.. DELETE FROM "table" WHERE "Column" = '1234' I'd rather delete entries from the first table by matching entries from a column in a second table. I've had a good go but don't yet have a good enough grasp of sql to figure it out for myself.

Hopefully thats clear and thanks in advance to anyone who can help

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2020-10-19 14:08:52.387122



If JohnSUN's answer helped then please click the checkmark on that answer. Otherwise, why should anyone spend time on this new question?

Jim K gravatar imageJim K ( 2017-11-04 15:46:05 +0100 )edit

I think what Jim K is trying to say, is that a thank you goes a long way here, as all questions are answered by volunteers. The best way to thank someone here is to up-vote their answer. There are two ways to do this, first you can click on the check box in the circle to say that this answer is the, or the best, answer for you. Also you can check the up arrow (in the vertical ^ # v set to the left of the answer's title.

EasyTrieve gravatar imageEasyTrieve ( 2017-11-04 17:48:36 +0100 )edit

I missed that checkmark and have corrected it accordingly

GarethT gravatar imageGarethT ( 2017-11-04 23:55:34 +0100 )edit

1 Answer

Sort by » oldest newest most voted

answered 2017-11-04 19:25:48 +0100

Ratslinger gravatar image


You don't provide much information on what conditions you are trying to satisfy 'by matching entries from a column in a second table. ' There are many examples around which may help


similar concept

Just a small sample of what is already available with a simple search.

Also, you do not state what database you are using. This can make a difference in the SQL used.

edit flag offensive delete link more


I agree its not a particularly well written question having looked back at it (probably not best off writing it whilst tired). I'll look over what you've posted tomorrow. Thanks for taking the time to point me somewhere at least though.

GarethT gravatar imageGarethT ( 2017-11-04 23:59:39 +0100 )edit

If you still have a problem after viewing links, please post additional info - DB used & exactly what determines if a record is to be deleted would be of great help.

Ratslinger gravatar imageRatslinger ( 2017-11-05 00:15:02 +0100 )edit

Still struggling, I have next to no experience with this kind of thing so please bear with me. I have two tables that both have a column called Tag. The first by necessity can have multiple records with the same tag number whilst the second allows no duplicates. Once a series of tag numbers is entered in to the second table, I'd like to be able to run an sql command to remove all rows with matching tag numbers from table one as they are no longer required there. Hopefully thats clearer

GarethT gravatar imageGarethT ( 2017-11-05 11:52:02 +0100 )edit

When it comes to deleting records you really need to be certain of what is to be deleted. Are you stating that if a tag exists in table "B", all records in table "A" containing that tag should be deleted? If so:


should work. Like any other test, make a backup copy first to insure this is actually the result wanted.

Ratslinger gravatar imageRatslinger ( 2017-11-05 14:57:23 +0100 )edit


Thats exactly what I was after so I've marked the question as answered Many thanks.

GarethT gravatar imageGarethT ( 2017-11-05 17:39:42 +0100 )edit

Question Tools

1 follower


Asked: 2017-11-04 12:08:32 +0100

Seen: 523 times

Last updated: Nov 04 '17