passing a scalar query result to coalesce
Posted
by Fakrudeen
on Stack Overflow
See other posts from Stack Overflow
or by Fakrudeen
Published on 2010-03-19T09:21:33Z
Indexed on
2010/03/19
9:31 UTC
Read the original article
Hit count: 232
mysql
How can I pass the result from a scalar [single row, single value] query to coalesce? I am trying to pick the priority as (the biggest priority so far in the table) + 1. [0 if it is the first row.]
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
)
© Stack Overflow or respective owner