嘿伙计,所以当我指定主要选择列名称时,我的查询不会返回我的联合结果,又名
SELECT inspection_number, region, report_date,
inspection_type AS type, customer, customer_number, shipper, po
FROM reports
JOIN (
(
SELECT `key`, `report_key`, `shipper`, `po`, `commodity`, `label`, `status`
FROM `berries`
)
UNION (
SELECT `key`, `report_key`, `shipper`, `po`, `commodity`, `label`, `status`
FROM `melons`
)
UNION (
SELECT `key`, `report_key`, `shipper`, `po`, `commodity`, `label`, `status`
FROM `citrus`
)
UNION (
SELECT `key`, `report_key`, `shipper`, `po`, `commodity`, `label`, `status`
FROM `table_grapes`
)
UNION (
SELECT `key`, `report_key`, `shipper`, `po`, `commodity`, `label`, `status`
FROM `tree_fruit`
)
UNION (
SELECT `key`, `report_key`, `shipper`, `po`, `commodity`, `label`, `status`
FROM `lot`
)
) fruits ON inspection_number = fruits.report_key
WHERE fruits.status = '0' OR fruits.status = '1'
ORDER BY report_date DESC
不会返回key
,report_key
,shipper
,po
,commodity
,label
或status
奇怪地跑步
SELECT *
inspection_type AS type, customer, customer_number, shipper, po
FROM reports
JOIN ( -- etc.....
威尔?我该如何解决这个问题?
答案 0 :(得分:1)
fruits 派生表确实有提到的列,但在主要选择中你没有提到任何一个;您只需从报告中提及列inspection_number,region,report_date,inspection_type - 因此它只显示它们。
如果要包含水果列,则需要在主选择语句中指定它们
即。类似的东西:
SELECT inspection_number, region, report_date,
inspection_type, key, report_key, shipper, po, commodity, label, status AS type, customer, customer_number, shipper, po, key, report_key, shipper, po, commodity, label, status
FROM reports
JOIN (