我试图在块
的情况下设置2声明变量这是我的代码:
DECLARE @like bit,@dislike bit
if exists
( select *
,@like = (CASE WHEN likeordislike = 1 THEN 'true' ELSE 'false' END)
,@dislike=(CASE WHEN likeordislike = 0 THEN 'true' ELSE 'false' END)
from likeordislike
)
但是当我执行查询抛出错误时:
Msg 102,Level 15,State 1,Line 4
'='附近的语法不正确。
一切都好吗?无法理解
答案 0 :(得分:1)
if (select count(*) from likeordislike where user = @user and comment_id = @comment_id) = 0
begin
insert into likeordislike etc
end
else
update likeordislike etc
end