請我怎麼能觸發這樣的事情,但沒有IF?可能嗎??MySql刪除觸發時,值爲空或非空
...
IF NEW.value IS NULL THEN
DELETE FROM table WHERE column IS NULL;
ELSE
DELETE FROM table WHERE column=NEW.value;
END IF;
練習時是null值那麼刪除行,其中列是空當值被設置成刪除與列行=值 我想這觸發沒有IF
請我怎麼能觸發這樣的事情,但沒有IF?可能嗎??MySql刪除觸發時,值爲空或非空
...
IF NEW.value IS NULL THEN
DELETE FROM table WHERE column IS NULL;
ELSE
DELETE FROM table WHERE column=NEW.value;
END IF;
練習時是null值那麼刪除行,其中列是空當值被設置成刪除與列行=值 我想這觸發沒有IF
你可以做一個單一的聲明:
...
DELETE FROM table WHERE column IS NULL OR column=NEW.value;
...
編輯:
DELETE FROM table WHERE (NEW.value IS NULL AND column IS NULL) OR (NEW.value IS NOT NULL AND column = NEW.value)
我想的if/else這將是functionnaly相當於你:
DELETE FROM table WHERE (NEW.value IS NULL AND column IS NULL) OR (column=NEW.value)
wrong..it是不是......我之前沒有測試......我想如果任何值,因此與空留記錄表 –
所以你想刪除哪裏列保存新值?檢查編輯。 – 1000111