gpt4 book ai didi

sql - 在需要条件的上下文中指定的非 bool 类型表达式,位于 'END' 附近

转载 作者:行者123 更新时间:2023-12-03 01:59:25 33 4
gpt4 key购买 nike

那么也许有人可以指出导致此错误的正确方向?我已经为此奋斗了几个小时并在网上搜索,但我不知道我在这里做错了什么。它作为存储过程的一部分包含在内,我不知道这是否重要,如果重要的话我也可以包含它。表和字段名称已更改以保护无辜者......这意味着我的工作。谢谢。

SELECT
/* The fields are here*/
FROM
/* my joins are here */
WHERE
(Table.Field = stuff)
AND
(Table.Field2 = otherstuff)
AND
(Table2.Field3 = someotherstuff)
AND
CASE @param1
WHEN 0 THEN 'Table.Field IS NULL'
WHEN 1 THEN 'Table.Field2 IS NOT NULL'
ELSE ''
END

感谢您的回复。从技术上讲,egrunin 是这个问题的正确答案,但 OMG Ponies 和 Mark Byers 几乎是同一件事,只是缺少最后一 block 。再次感谢。

最佳答案

我很确定其他答案遗漏了一个案例:

WHERE 
(Table.Field = stuff)
AND
(Table.Field2 = otherstuff)
AND
(Table2.Field3 = someotherstuff)
AND
(
(@param1 = 0 and Table.Field IS NULL)
OR
(@param1 = 1 and NOT Table.Field2 IS NULL)
OR
(@param1 <> 0 AND @param1 <> 1) -- isn't this needed?
)

关于sql - 在需要条件的上下文中指定的非 bool 类型表达式,位于 'END' 附近,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3018549/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com