如何将标量[单行,单值]查询的结果传递给合并?我试图选择优先级(到目前为止表中最大的优先级)+ 1. [0如果它是第一行。]
create trigger priority_SuperRuleSamples before insert on SuperRuleSamples
FOR EACH ROW
SET NEW.Priority=coalesce(NEW.Priority,
coalesce(
select Priority from SuperRuleSamples order by Priority desc limit 1,
-1
)+1
)
答案 0 :(得分:0)
您的查询中似乎存在括号问题。你能试试吗?
create trigger priority_SuperRuleSamples before insert on SuperRuleSamples
FOR EACH ROW
SET NEW.Priority=coalesce(NEW.Priority,
coalesce(
(select Priority from SuperRuleSamples order by Priority desc limit 1),
-1
)+1
)