一条查询语句,思路混乱了
本帖最后由 SkyLee708 于 2013-08-27 21:03:06 编辑
            比如 某表
  A      B      C      D
张三     10      0
张三      0     10
李四     10      0
王五     10     10
赵六      0     10
孙七     20     20
'select * from 表 where D <> 0  and A like''%张三%'' and B=10 or C=10'
结果出来
A        B      C      D
张三     10     0
张三      0     10
王五     10     10
赵六      0     10
想要结果是
A        B      C      D
张三     10      0
张三      0     10
一条查询语句,思路混乱了,求老师指点思路
              
------解决方案--------------------select * from 表 where D <> 0  and A like''%张三%'' and (B=10 or C=10)
------解决方案--------------------
这个不太对 ,看下下面这个吧
Declare @table table(A nvarchar(10),B int ,C int ,D int)
insert @table
select N'张三', 10, 0,null	union all
select N'张三',  0,10,null	union all