注册 登录
编程论坛 SQL Server论坛

这句话如何写(查询)

jxawgyl 发布于 2008-06-24 08:56, 1072 次点击
SQL:select * from RecipeView  where  executeoffice= 4008
    and addtime>='2008-06-20'
    and addtime<='2008-6-23'
   and medsortname=''
    and doccode= ''
   and opecode= ''
其中medsortname='',    and doccode= '',   and opecode= ''这三个条件只有一个存在时,如何才能使之能查询
也就是这三个条件都为空时,也可以查询。
5 回复
#2
bb38522008-06-24 16:21
select * from RecipeView  where  executeoffice= 4008
    and addtime>='2008-06-20'
    and addtime<='2008-6-23'
   and (medsortname=''
    or doccode= ''
   or opecode= '')
不知道是不是我理解错误了
#3
jxawgyl2008-06-26 08:32
我是这样改的:
SQL:select * from RecipeView  where  executeoffice= 4008
    and addtime>='2008-06-20'
    and addtime<='2008-6-23'
   and medsortname like'%'
    and doccode like '%'
   and opecode like '%'
#4
tomtory2008-06-26 14:13
就二楼那种就可以了啊 将=好改为你的模糊查询就可以了
#5
2008-06-27 23:59
这主要看你的表允不允许那三列为空值
#6
雪雨星风2008-06-28 09:04
恩同意二楼的
1