0

表 1 - 此表完全由 XLSX 文件填充...

在此处输入图像描述

表 2 和表 3 - 包含最终表中几列的 1-1 个参考。

在此处输入图像描述

表 3 - 我正在尝试填充前三个表....

在此处输入图像描述

如您所见,这些表格是合理的,没有进行爱因斯坦方程或转换。这是我已经尝试过的代码,但未成功:

INSERT INTO att_oem_orders SELECT NULL, ost.om_or_po, (SELECT j.job_id FROM jobs j WHERE j.project_number = project_no), NULL, (SELECT ao.id FROM att_oem WHERE ao.item_no = item_no), ost.po_number, (SELECT ol.id FROM order_lsc WHERE STATUS = ol.line_status_code), ost.ordered_date, ost.shipment_date, NULL, NULL, ost.item_qty, NULL, NULL, NULL, NULL, ost.shipping_to, ost.tracking_number, ost.carrier) FROM oem_temp_sync WHERE ost.item_qty > 0
4

2 回答 2

1

尝试使用 FIRST() 限制要放入字段的可能值的数量,如下所示:

INSERT INTO att_oem_orders SELECT
    NULL,
    ost.om_or_po,
    (SELECT FIRST(j.job_id) FROM jobs j WHERE j.project_number = project_no),
    NULL,
    (SELECT FIRST(ao.id) FROM att_oem WHERE ao.item_no = item_no),
    ost.po_number,
    (SELECT FIRST(ol.id) FROM order_lsc WHERE STATUS = ol.line_status_code),
    ost.ordered_date,
    ost.shipment_date,
    NULL,
    NULL,
    ost.item_qty,
    NULL,
    NULL,
    NULL,
    NULL,
    ost.shipping_to,
    ost.tracking_number,
    ost.carrier
FROM oem_temp_sync WHERE ost.item_qty > 0

您似乎在 FROM 之前还有一个额外的 )

于 2013-09-30T14:24:56.573 回答
0

在大家的一点点帮助下,我发现了一些错误并修复了一些子查询。这是最终版本:

INSERT INTO att_oem_orders 
SELECT 
    NULL,
    ost.om_or_po,
    (SELECT 
        FIRST(j.id) 
    FROM
        jobs j 
    WHERE j.project_number = ost.project_no),
    NULL,
    (SELECT 
        FIRST(ao.id) 
    FROM
        att_oem ao
    WHERE ao.item_no = ost.item_no),
    ost.po_number,
    (SELECT 
        FIRST(ol.id) 
    FROM
        att_oem_lsc ol
    WHERE ol.status = ost.line_status_code),
    ost.ordered_date,
    ost.shipment_date,
    NULL,
    NULL,
    ost.item_qty,
    NULL,
    NULL,
    NULL,
    NULL,
    ost.ship_to,
    ost.tracking_no,
    ost.carrier
FROM
    oem_sync_temp  ost
WHERE ost.item_qty > 0
于 2013-09-30T17:02:25.150 回答