I’m trying to make a trigger that updates a table, and here’s some psuedo code:
IF db.table1.column5 = 1
{UPDATE db.table5.column5 = 1;}
ELSE IF
db.table2.column5 = 1
{UPDATE db.table5.column5 = 1;}
ELSE IF
db.table3.column5 = 1
{UPDATE db.table5.column5 = 1;}
ELSE IF
db.table4.column5 = 1
{UPDATE db.table5.column5 = 1;}
What would be the most efficient way to do that? For example, should I just make a bunch of triggers, or should I use the OR keyword or ELSE IF, like above? Could someone show me how the code is formed, please? It’s my first time doing this.
Thanks for reading.
If I understand your requirements, any time
column5is updated in table1 through table4, you want to update the corresponding row in table5 as well?You will want to use multiple triggers for this, one on each of table1 through table4.