SQL连接不起作用

时间:2016-03-18 18:18:41

标签: mysql sql database join db2

我正在尝试将这两个查询合并到一个联接中,但它没有那么好用,你能告诉我哪里出错了。提前致谢

SELECT z1blto, 
       z1ctrk 
FROM   z1mast AS e 
JOIN   d 
       ( 
                select   a.ordprod, 
                         a.ordtotpcs , 
                         a.ordordnum, 
                         b.orhdate 
                FROM     dta/dw30d a 
                JOIN     dta/dw30c b 
                ON       a.ordcust = b.orhcust 
                AND      a.ordordnum = b.orhordnum 
                WHERE    a.ordcust = 'GL02' 
                AND      a.ordprod = '2002534B_GC' 
                ORDER BY b.orhdate) AS d 
ON     e.z1cucd = d.ordcust

1 个答案:

答案 0 :(得分:0)

您的查询中似乎有拼写错误。您的ON规范使用ordcust表示{和orhcust表示b,类似于ordornumorddate。这是更正后的版本。并且在嵌套查询之前还有一个额外的d。我正在做一些关于拼写的假设,因为你的问题中缺少信息。

SELECT z1blto, 
       z1ctrk 
FROM   z1mast AS e 
JOIN   
       ( 
                select   a.ordprod, 
                         a.ordtotpcs , 
                         a.ordordnum, 
                         b.orddate 
                FROM     dta/dw30d a 
                JOIN     dta/dw30c b 
                ON       a.ordcust = b.ordcust 
                AND      a.ordordnum = b.ordordnum 
                WHERE    a.ordcust = 'GL02' 
                AND      a.ordprod = '2002534B_GC' 
                ORDER BY b.orddate) AS d 
ON     e.z1cucd = d.ordcust