Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting a variable with select inside coalesce

How do I fix up this part of my stored procedure?

The select will either return 1, 0, or null. If the select returns 1 or 0, I want @override to be set to that value. If it returns null, then I want @override to be set to 1.

Something is wrong with my syntax; I am told "incorrect syntax near 'select'" and "incorrect sytax near ')'".

Here is the sql:

set @override = (coalesce(select override from groupPreferences g inner join
preferences p on g.preferenceId = p.preferenceId where groupId = 13
and description = 'myDescription'), 1))
like image 325
dmr Avatar asked Dec 13 '25 04:12

dmr


1 Answers

set @override = (coalesce((select override from groupPreferences g inner join
preferences p on g.preferenceId = p.preferenceId where groupId = 13
and description = 'myDescription'), 1))
like image 165
bodee Avatar answered Dec 14 '25 18:12

bodee



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!