StrSql = "insert into ttlybb(shipid,shipname,hz,nwm,jcg,dw,dgrq,kbrq,lgrq,tkbw,kgrq,mtmc) "
StrSql = StrSql + "select cbdtcx.shipid,cbdtcx.shipname,cbdtcx.hz,cbdtcx.nwm,cbdtcx.jcg,cbdtcx.dw,cbdtcx.dgrq,cbdtcx.kbrq,cbdtcx.lgrq,cbdtcx.tkbw,zyjhs.kgrq,bw.mtmc From cbdtcx "
StrSql = StrSql + " inner join zyjhs on zyjhs.shipid = cbdtcx.shipid and zyjhs.dw = cbdtcx.dw "
StrSql = StrSql + " inner join bw on bw.bwid = cbdtcx.tkbw and bw.dw = cbdtcx.dw "Conn.Execute StrSql问题是当我用到其中任一个inner join时,都能正常实现,两个都用时就会提示出错,提示在查询表达式''中出错,请教是什么原因?我想要用多表关联,但现在单表关联没问题,两表就不行了?是哪错了?请高手帮忙看看

解决方案 »

  1.   

    '最后两句改为试试:
    StrSql = StrSql + " inner join zyjhs on zyjhs.shipid = cbdtcx.shipid and ON zyjhs.dw = cbdtcx.dw "
    StrSql = StrSql + " inner join bw on bw.bwid = cbdtcx.tkbw and ON bw.dw = cbdtcx.dw "
      

  2.   

    '看错
    '最后两句改为试试:
    StrSql = StrSql + " ((inner join zyjhs on zyjhs.shipid = cbdtcx.shipid and zyjhs.dw = cbdtcx.dw) "
    StrSql = StrSql + " inner join bw on bw.bwid = cbdtcx.tkbw and  bw.dw = cbdtcx.dw ) "其实 INNER JOIN ……ON的语法格式可以概括为:
    FROM (((表1 INNER JOIN 表2 ON 表1.字段号=表2.字段号) INNER JOIN 表3 ON 表1.字段号=表3.字段号) INNER JOIN 表4 ON Member.字段号=表4.字段号) INNER JOIN 表X ON Member.字段号=表X.字段号
    您只要套用该格式就可以了。
      

  3.   

    winehero(编程人生) **********
    StrSql = "insert into ttlybb(shipid,shipname,hz,nwm,jcg,dw,dgrq,kbrq,lgrq,tkbw,kgrq,mtmc) "
    StrSql = StrSql + "select cbdtcx.shipid,cbdtcx.shipname,cbdtcx.hz,cbdtcx.nwm,cbdtcx.jcg,cbdtcx.dw,cbdtcx.dgrq,cbdtcx.kbrq,cbdtcx.lgrq,cbdtcx.tkbw,zyjhs.kgrq,bw.mtmc From ((cbdtcx "
    StrSql = StrSql + " inner join zyjhs on zyjhs.shipid = cbdtcx.shipid and zyjhs.dw = cbdtcx.dw) "
    StrSql = StrSql + "inner join bw on bw.bwid = cbdtcx.tkbw and bw.dw = cbdtcx.dw) "
    改成这样行了,但两个条件时不能用两个ON,谢了.