Skip to content

Tag: triggers

Trigger to create or update records in another table

Edit: This question is mostly solved. What I am still trying to do might require a different approach. I am adding a trigger to a legacy database table, in order to automatically create new records for a related table. This is not homework. Here is my DB Fiddle on SQL Server 2017. For example, here is what the parent

MySQL Trigger Nested Group_Concat Duplicates

I have a trigger to conditionally GROUP_CONCAT a few columns. I can remove duplicates from within a single column, but Iā€™m struggling to remove duplicates between two or more columns. Current trigger (two column example): Fiddle: Answer Change the second Select to āœ“ āœ“ id | selection1 | selection2 | results -: | :——— | :——— | :—— 1

How can I make the trigger return a value?

I have a ‘roomstate’ table that represents states that I keep updated. This is what happens when the employee assigns room 2 to customer 1 whose booking_id is 2. As the table above is continuously updated, the existing contents may become NULL again. I’d like to have a record of updating this in another table. example : So, I used

How can I make my sql trigger about inappropiate words work

I have a database with different tables in order to store photos, users, reviews, ratings… I wanna validate that no one uses “bad words” (insults) in their photos’ title or description. So I decided to create a table called ‘inappropiatewords’ where all of these bad words will be stored and then I made the following trigger: But when I try