两个select语句的内部连接期间的语法错误

时间:2016-05-27 06:44:46

标签: mysql join

下面的sql查询在内部连接部分期间出现了一些错误,这是错误消息:

  

您的SQL语法有错误;检查手册   对应于您的MySQL服务器版本,以便使用正确的语法   靠近'作为内部联接(从STOCK.WAREHOUSE_MVT_LINE中选择SERIAL_NO   mvtLn INNER'在第3行

@Override
public void onCompleted(JSONObject object, GraphResponse response) {

    FacebookRequestError error = response.getError();
    if (error != null) {
        // handle your error
        return;
    }

    try {
        String id = object.getString("id");
        ...

1 个答案:

答案 0 :(得分:0)

你想要这个吗?

SELECT wm.CID, wm.DOC_ID, wm.DOC_TYPE, wml.SERIAL_NO, wml.WH_MVT_NO
    , wm.PROD_ID, wm.LOT_CODE, wm.WH_CODE, wm.BIN_CODE, wml.MVT_DATE
    , wm.BATCH_NO, wm.MVT_TYPE, wm.PROD_NAME, wm.COMMENT, wm.REMARK
    , wm.NOTE, wm.INSTRUCTION
FROM STOCK.WAREHOUSE_MVT_LINE wml INNER JOIN STOCK.WAREHOUSE_MVT wm ON wml.CID = wm.CID
AND wml.WH_MVT_NO = wm.WH_MVT_NO
WHERE wml.CID = 70200009
    AND wm.MVT_TYPE != 'TFOUT'
    AND wm.MVT_TYPE != '3TFOUT'
    AND wml.SERIAL_NO IN (
            SELECT a.SERIAL_NO FROM -- You missed this. I thought....
            (
                SELECT SERIAL_NO
                FROM STOCK.WAREHOUSE_MVT_LINE mvtLn
                INNER JOIN STOCK.WAREHOUSE_MVT mvt
                ON mvtLn.CID = mvt.CID
                AND mvtLn.PFC_CODE = mvt.PFC_CODE
                AND mvtLn.WH_MVT_NO = mvt.WH_MVT_NO
                WHERE mvtLn.CID = 70200009
                AND mvtLn.PFC_CODE = 'SG'
                AND mvtLn.MVT_DATE >= '2016-04-01 00:00:00.0'
                AND mvtLn.MVT_DATE <= '2016-06-30 00:00:00.0'
                AND mvt.WH_CODE = 'IDJKT'
                AND mvt.BIN_CODE = 'IMP'
            ) a
            INNER JOIN (
                SELECT SERIAL_NO
                FROM STOCK.WAREHOUSE_MVT_LINE mvtLn
                INNER JOIN STOCK.WAREHOUSE_MVT mvt
                ON mvtLn.CID = mvt.CID
                AND mvtLn.PFC_CODE = mvt.PFC_CODE
                AND mvtLn.WH_MVT_NO = mvt.WH_MVT_NO
                WHERE mvtLn.CID = 70200009
                AND mvtLn.PFC_CODE = 'SG'
                AND mvtLn.MVT_DATE >= '2016-01-01 00:00:00.0'
                AND mvtLn.MVT_DATE <= '2016-03-31 00:00:00.0'
                AND mvt.WH_CODE = 'CL'
                AND mvt.BIN_CODE = 'PSADEPOT'
            ) b ON a.SERIAL_NO = b.SERIAL_NO )
    AND wm.MVT_DATE BETWEEN '2016-01-01 00:00:00.0' AND '2016-06-30 00:00:00.0'
ORDER BY wml.SERIAL_NO, wml.MVT_DATE