0

I need to write a trigger which deletes a row when two cells in same row has a value of 0. When user updates or insert values to table and both qty1 and qty2 is becomes 0, then this row should be removed. In table shown below, last row should be removed

+------------+------+------+
|    date    | qty1 | qty2 |
+------------+------+------+
| 2019-03-28 | 1    | 1    |
+------------+------+------+
| 2019-03-28 | 1    | 0    |
+------------+------+------+
| 2019-03-28 | 0    | 1    |
+------------+------+------+
| 2019-03-28 | 0    | 0    |
+------------+------+------+

i need that after update last row is removed.

Kalle
  • 69
  • 7
  • 1
    You cannot do this in a trigger because a trigger cannot modify the table it is attached to beyond modifying individual field values through the NEW.fieldname syntax. – Shadow Mar 29 '19 at 13:23
  • Some options to deal with it are mentioned here: https://stackoverflow.com/questions/5885715/mysql-triggers-to-delete-child-records-in-the-same-table – J.R. Mar 29 '19 at 22:07

0 Answers0