SQL查询语句. 解答后,马上给分!!!!!!!!!!!!!
select *,mdriver.ElinkCoAddr,mdriver.ElinkCoTel from [Border] left outer join MDriver on Border.PlateNo=MDriver.PlateNo
and Border.GroupCoCode=MDriver.GroupCoCode where isnull(ShprCode,'') like '%%' and isnull(CneeCode,'') like '%%' and isnull(TruckCoCode,'') like '%'and isnull(DlvrAddrCode,'') like '%%' and (isnull(DlvrAddrCityCn,'')
like '%%' or isnull(DlvrAddrCityEn,'') like '%%') and (JobDateTime >= CONVERT(DATETIME, '2008-4-01', 102))
and (JobDateTime <= CONVERT(DATETIME, '2050-01-01', 102))and BOrder.GroupCoCode='VHK'
and BOrder.WayBillNo='12'
order by JobDateTime DESC
执行上面这条sql语句后没报错,但没有任何结果. 我把and 改or就显示所有的结果了,WayBillNo不是 ‘12’的也查询出来了。
请问:and BOrder.WayBillNo='12' 这里应该怎么改?
------解决方案--------------------
不大明白你在说什么
BOrder.GroupCoCode='VHK'
and BOrder.WayBillNo='12'
你看看是否有满足这两个条件的数据
别外,or是或者的关系,相当于
select * from table where BOrder.GroupCoCode='VHK'
union all
select * from table where BOrder.WayBillNo='12'
自然 WayBillNo不是 ‘12’的也查询出来了
------解决方案--------------------所学甚浅,不过字段是数字时不用单引号吧