Playing around with some SQL to DELETE a Record from a Table if (a) it exists and (b) and entry related to that record doesn't exist in another Table.

Say I have Table1 with columns: ID and Name, and Table2 with columns: ID1 and Name, the records are related by the Name columns.

I could use 2 SQL statement, one to SELECT the Name from Table1 WHERE the ID = the ID I'm looking for, then, if anything was returned, SELECT FROM Table2 where Name= the Name returned from the first SELECT. If nothing is returned then DELETE FROM Table1 WHERE ID = the ID I'm looking for.

I was looking at how I could avoid using 2 SELECTS and came up with:

SELECT ID1 FROM Table2 WHERE Name IN (SELECT Name FROM Table1 WHERE ID = 1)

I could test the results from that query and if nothing was returned DELETE the record from Table1

The 'problem' I see is that the query will also return nothing if no record is found in Table1 with an ID of 1, so I would end up attempting to DELETE a non-existent record from Table1. Presumably that wouldn't 'matter' but is there a better way of achieving the result ?