0

So basically what i want to do is to delete columns with the value NULL after an Insert. My brain must be afk or something. Here is what i tried:

BEGIN
Update `table`

delete from test
where table.name is null;

END

or

BEGIN 

  DELETE FROM table WHERE (NEW.value IS NULL AND name IS NULL)

END

This is the Error Message:

SQLSTATE[HY000]: General error: 1442 Can't update table 'Test' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.

This only occurs when i insert the code above. I have nothing else this is the first trigger i implement in the database.

Devi
  • 87
  • 1
  • 12
  • 1
    Possible duplicate of [MySQL - Trigger for updating same table after insert](https://stackoverflow.com/questions/12877732/mysql-trigger-for-updating-same-table-after-insert) – Madhur Bhaiya Nov 16 '18 at 11:52
  • 1
    Possible duplicate of [MySQL Trigger to prevent INSERT under certain conditions](https://stackoverflow.com/questions/2981930/mysql-trigger-to-prevent-insert-under-certain-conditions) – Nick Nov 16 '18 at 11:53
  • 1
    Please provide sample data and desired results. "Deleting columns" doesn't make sense, and "dropping columns" is not something normally done to a table -- in a trigger or otherwise. – Gordon Linoff Nov 16 '18 at 11:54
  • Sorry i meant records not columns – Devi Nov 16 '18 at 13:18
  • @MadhurBhaiya Its no duplicate question. – Devi Nov 16 '18 at 13:20

0 Answers0