I'm trying to make a simple decision deleting records from database. I have a main table with records and the unique ID it's auto increment.
Then I have a second table that stores values(could be more than one) associating the ID from the first table.
Example:
table1
editors
ID (autoincrement)
EditorName
Then I have a second table with:
table2
ID
editorID (same ID as table1)
bookname
So this way I want to know how could be the best way to delete a record from table1 (example ID=2) and it automatically deletes all records from table2 where editorID=2.
I've tried many ways but it seems they don't work unless I do two queries but I don't like that way. There's a smarter way to do that? It must be by code or I could associate two tables in SQL and they associated by ID and editorID?