- 爱易网页
 
                        - 
                            MSSQL教程
 
                        - 某一列满足两个条件如何查 
 
                         
                    
                    
                    日期:2014-05-18  浏览次数:20707 次 
                    
                        
                         某一列满足两个条件怎么查?
表结构如下:
name    col
a       1
a       2
a       2
b       3
b       4
c       1
d       2
如果传入的值为:1,2
那么分组查询满足1,2在col的数据
只有a满足
怎么查询?
------解决方案--------------------
or:
SELECT name 
from tb a
where col =1
and exists (
select 1 from tb
where name = a.name
and col = 2
)
or:
SELECT distinct a.name 
from tb a,tb b
where a.col =1
and b.name = a.name
and b.col = 2
                        
                     
                    
                    
                        免责声明: 本文仅代表作者个人观点,与爱易网无关。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。