知识屋:更实用的电脑技术知识网站
所在位置:首页 > 编程技术  > ASP编程

asp多表联合查询语句 asp中用sql语句联合查询多个表

发表时间:2017-04-05来源:网络

asp多表联合查询语句 asp中用sql语句联合查询多个表。我们在使用电脑的时候,总是会遇到很多的电脑难题。当我们需要使用ASP夺标联合查询的时候,我们应该怎么操作呢?一起来看看吧。


  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


(免责声明:文章内容如涉及作品内容、版权和其它问题,请及时与我们联系,我们将在第一时间删除内容,文章内容仅供参考)
收藏
  • 人气文章
  • 最新文章
  • 下载排行榜
  • 热门排行榜