New answers tagged

0

Thanks to @ Justin Cave I got the answer. The problem was that another table (Department) was referencing the Store table as well. so I added in the trigger body: DELETE FROM Department WHERE Department.storeCode = :oldRow.stCode;


2

You could use a trigger which insert into table2 what has been removed from table1. CREATE TABLE table1(id int, name varchar(10), level int); INSERT INTO table1(id, name, level) VALUES (0, 'a', 0) , (1, 'b', 1) , (2, 'c', 0) , (3, 'd', 2) , (4, 'e', 1) , (4, 'f', 0); CREATE TABLE table2(id int, name varchar(10), level int); DELIMITER // ...


1

Insert everything into a temp table first. Then your insert and delete are simply everything from the temp table rather than your complicated query. This solves your problem of how to do both halves and is probably going to perform better than running your complicated query multiple times. I do more MS-SQL than My-SQL so I'll link to another answer on Stack ...


1

To solve this problem I did the following. Created the table as per the question above. I then populated it with this data (a bit extra added for testing purposes). INSERT INTO c_example VALUES (1, 1, '313f516ad35e477482aa435ae53c6b3a', 1, '2016-05-09 21:53:14'), (2, 1, '313f516ad35e477482aa435ae53c6b3a', 2, '2016-05-09 21:53:14'), (3, 1, '...



Top 50 recent answers are included