I am trying to build a SQL query that removes domains from a PowerDNS database. The tables are called, domains and domains_status. I want to delete both records only if domains_status where the columns name domain_regStatus = 0. The ID value is the same for both domains and domain_status.
Here is an example of how the database looks,
Use
DELETEwith a join between the tablesIf
domain_status.domain_idis declared as a foreign key withON DELETE CASCADE, you only need to delete from thedomainstable, it will automatically delete fromdomain_status. So change to: