看了資料庫的觸發器,就想,如果某個定單表插入的數量大於商品表,那麼商品表應該是負數啊,應該加以限制。可是我採用before來限制時,則不能執行,誰幫我看下這串程式碼哪錯了
create trigger tg1
before insert on ord
for each row
begin
##if new.o_num > goods.g_num thenset new.o_num = goods.g_numend if; update goods set g_num = g_num - new.o_num where gid = new.gid;end$ll2018-08-13 17:36:39
if new.o_num > goods.g_num then
set new.o_num = goods.g_num
當DD的數量大於庫存數量你讓DD的數量等於庫存的數量了你可以用phpmyadmin來建造觸發器