Table A:
Venid Venname
0001 Company 1
0002 Company 2
Table B:
Docno Venid CDATE
20090001 0001 2009-01-01
20090002 0002 2009-01-02
20090003 0001 2009-01-03
C Table:
Docno PLU STORY
20090001 1111 25
20090001 2222 20
20090002 3333 15
20090002 4444 25
20090003 1111 20
20090003 5555 15
(I'm now going to query for records based on PLU or Docno or CDate, as listed below)
Dan (DOCNO) company name (venname) Date (CDATE)
20090001 Company 1 2009-01-01
20090002 Company 2 2009-01-02
20090003 Company 1 2009-01-03
Method One:
SELECT * from A,b where A.venid=b.venid and Docno into (select Docno from C where docno= ' "&s_dingdan&" ' or pluid= ') &A mp;s_tiaoma& "') Order by recedate Desc
Method Two:
SELECT * from A,b where A.venid=b.venid and Docno in (select Docno from B where (replace) (CONVERT (char), createdate,111), '/ ', '-') between ' "&s_riqi&" and "&s_riqi2&") Order BY recedate Desc "
SELECT * from A,b where A.venid=b.venid and Docno into (select Docno from C where docno= ' "&s_dingdan&" ' or pluid= ') &A mp;s_tiaoma& "') Order by recedate Desc