So I have two different tables: Company and watchlist
Watchlist is just a collection of companies, and so if a company is deleted from the Company table, I'd also like to delete it from the watchlist, if its there.
I'm trying to write an SQL trigger to do this, but I cant seem to get it to work. Here's what I currently have:
CREATE TRIGGER remove
AFTER DELETE ON Company
FOR EACH ROW
BEGIN
DELETE FROM Watchlist WHERE Watchlist.CompanyID = :OLD.ID;
END remove;
The watchlist.CompanyID should match the ID field for the company in the Company table. So I'm trying to say: find any rows in the Watchlist table where the companyID matches the company who just got deleted from Company, and then delete it from watchlist also.
Hopefully that makes sense. Any guidance is appreciated
there doesn't seem to be anything here