Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
对于sql中的多个and语句,可以以任何方式将多个or语句编写为_Sql_Sql Server - Fatal编程技术网

对于sql中的多个and语句,可以以任何方式将多个or语句编写为

对于sql中的多个and语句,可以以任何方式将多个or语句编写为,sql,sql-server,Sql,Sql Server,上述声明可以写成 select * from Table1 where fieldname = 'a' or fieldname = 'b' or fieldname = 'c' 有没有办法速记“和”陈述 select * from Table1 where fieldname in ('a', 'b', 'c') 更新< /强>:考虑情况 select * from Table1 where fieldname = 'a' and fieldname = 'b' and fieldna

上述声明可以写成

select * from Table1 where fieldname = 'a' or fieldname = 'b' or fieldname = 'c' 
有没有办法速记“和”陈述

select * from Table1 where fieldname in ('a', 'b', 'c')

<强>更新< /强>:考虑情况

select * from Table1 where fieldname = 'a' and fieldname = 'b' and fieldname = 'c' 

这在逻辑上甚至是不可能的

对于任何记录,如果fieldname的值为“a”,则fieldname不能有值“b”(即fieldname='a'然后fieldname!='b')。这意味着fieldname对于单个记录不能有多个值

如果您写入
,其中fieldname='a'和fieldname='b'以及fieldname='c'
将给出空结果


因此,没有办法速记

这在逻辑上甚至是不可能的

对于任何记录,如果fieldname的值为“a”,则fieldname不能有值“b”(即fieldname='a'然后fieldname!='b')。这意味着fieldname对于单个记录不能有多个值

如果您写入
,其中fieldname='a'和fieldname='b'以及fieldname='c'
将给出空结果


所以没有办法速记

条件是错误的。结果集将始终为空。是的,这会给出相同的结果:从表1中选择*,其中1=0我认为您有
困惑…如果您实际上要查找多行(对于其他列)必须匹配条件,您可能正在查找“关系分割”。否则,正如人们所指出的,在
fieldname='a'
fieldname='b'
之间不能有任何行。您的更新也没有为我提供任何启发-这是输入还是结果?无论哪种方法,你都能生产出另一种吗?条件是错误的。结果集将始终为空。是的,这会给出相同的结果:从表1中选择*,其中1=0我认为您有
困惑…如果您实际上要查找多行(对于其他列)必须匹配条件,您可能正在查找“关系分割”。否则,正如人们所指出的,在
fieldname='a'
fieldname='b'
之间不能有任何行。您的更新也没有为我提供任何启发-这是输入还是结果?不管哪种方式,你能生产另一种吗?
fieldname ID
--------------------
a         1   
a         2
b         3
c         4  
b         5
a         6