开发者

How to Combine Two SQL Queries

How can I combine the two sql queries into one:

strQuery = "select * from UNITHD where driver1medical BETWEEN '1/1/1开发者_运维知识库990' and GETDATE()+29 ORDER BY driver1medical"
objMedicalDriver1.Open strQuery

and

strQuery = "select * from UNITHD where driver2medical BETWEEN '1/1/1990' and GETDATE()+29 ORDER BY driver1medical"
objMedicalDriver2.Open strQuery

I did find alot of examples here at stackoverflow but I just cannot get it to work :-(


select * from UNITHD
where ( driver1medical BETWEEN '1/1/1990' and GETDATE()+29 )
   or ( driver2medical BETWEEN '1/1/1990' and GETDATE()+29 )
ORDER BY driver1medical


That way it should list all resultds combined, remember that to use the UNION operand, you need to replace * for the list of attributes in both queries so that they match (both in number and in domain):

select * from UNITHD where driver1medical BETWEEN '1/1/1990' and GETDATE()+29 ORDER BY driver1medical

UNION

select * from UNITHD where driver2medical BETWEEN '1/1/1990' and GETDATE()+29 ORDER BY driver1medical
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜