表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
答案 0 :(得分: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
之前,你似乎还有一个额外的东西答案 1 :(得分: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