简体   繁体   English

在SQL Server中查询2个不同值的特定列

[英]Query specific column for 2 different values in SQL Server

I don't have much experience with database so this might look silly. 我没有太多的数据库经验,所以这看起来很愚蠢。

I just can't query the same column for 2 different values. 我只是无法在同一列中查询2个不同的值。

This is what I am trying: 这是我正在尝试的:

where  b.idIndice = 10 and b.idIndice = 20

I have both values in this column 我在此列中都有两个值

Thanks 谢谢

你的意思是:

SELECT * FROM TBL b WHERE b.idIndice IN (10, 20)

Try : 尝试:

WHERE b.idIndice = 10 OR b.idIndice = 20

Or 要么

WHERE b.idIndice IN(10, 20)

A value can't be equal to 10 and to 20 at the same time. 一个值不能同时等于10和20。

use in () 用于 ()

where b.idIndice in (10,20) 其中b.idIndice在(10,20)

refer here 请参考这里

http://www.techonthenet.com/sql/in.php http://www.techonthenet.com/sql/in.php

WHERE  b.idIndice = 10 OR b.idIndice = 20

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM