我使用了永远正确的陈述,例如1 = 1
在MYSQL中where子句的case语句,语法如下:
select * from tablename where
(case when tablefield is not null then
then tablefield = 'value'
else 1 = 1 end)
我想知道如何在 sqlserver/tsql case 语句的 where 子句中使用 else 1 = 1
(始终为 true 语句)。
最佳答案
你不会使用 case 你只会写一个多条件语句。在你的情况下它看起来像
Where (tablefield = 'value'
OR tablefield is null)
关于mysql - sql server 中 where 子句中的 case 语句与 else 始终为真,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28865989/