对于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