I have a table called "changes" which contains a list of record numbers the user has modified on many other tables. I'd like to remove the record referenced by a row in changes (and the changes row itself) in one SQL query.
WITH name AS ( SELECT tableName FROM [changes] WHERE id = 80 ),
number AS ( SELECT changeRecnum FROM [changes] WHERE id = 80 )
DELETE FROM [name] WHERE changeRecnum = number
DELETE FROM [changes] WHERE id = 80
Unfortunately, I keep getting errors about how 'changeRecnum' and 'number' are invalid column names.