MySQL Forums
Forum List  »  Triggers

Re: Trigger to limit number of rows in another table
Posted by: Peter Brawley
Date: May 26, 2020 09:03AM

You'd need Insert & Update Triggers on Table 1, each saying something like ...

declare n smallint;
set n = ( select count(*) from table2 ) - NEW.MaxNumberOfRowsTable2;
if n > 0 then
delete from table2 order by id limit n;
end if;

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Trigger to limit number of rows in another table
230
May 26, 2020 09:03AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.