日期:2014-05-18  浏览次数:20626 次

筛选同一个字段中的两种数据的方法
我的表A中有4个字段a1,a2,a3,a4 a1中有两种数据是我需要筛选出来的,如 ab和ac,我现在的查询是以下这样的,不能得出正确数据。
select * from a where a.a1=ab and a.a1=ac

请问高手问题在哪里?

------解决方案--------------------
如果a1是字符串:
SQL code
select * from a where a.a1='ab' or a.a1='ac'

------解决方案--------------------
或者
SQL code
select * from a where a.a1='ab' 
union all
select * from a where a.a1='ac'