A表:
VENID VENNAME
0001 公司1
0002 公司2
B表:
DOCNO VENID CDATE
20090001 0001 2009-01-01
20090002 0002 2009-01-02
20090003 0001 2009-01-03
C表:
DOCNO PLU STORY
20090001 1111 25
20090001 2222 20
20090002 3333 15
20090002 4444 25
20090003 1111 20
20090003 5555 15
(我现在要根据 PLU或者DOCNO或者CDATE来查询得到记录,并如下列出)
单号(DOCNO) 公司名称(VENNAME) 日期(CDATE)
20090001 公司1 2009-01-01
20090002 公司2 2009-01-02
20090003 公司1 2009-01-03
方法一:
select * from A,B where A.VENID=B.VENID and DOCNO in(select DOCNO from C where DOCNO='"&s_dingdan&"' or PLUID='"&s_tiaoma&"')order by RECEDATE desc
方法二:
select * from A,B where A.VENID=B.VENID and DOCNO in(select DOCNO from B where(replace(CONVERT(char(10),CREATEDATE,111),'/','-') between '"&s_riqi&"' and '"&s_riqi2&"')) order by RECEDATE desc"
select * from A,B where A.VENID=B.VENID and DOCNO in(select DOCNO from C where DOCNO='"&s_dingdan&"' or PLUID='"&s_tiaoma&"')order by RECEDATE desc