1. 程式人生 > >UNION ALL 小結

UNION ALL 小結

statement tor house nbsp 語句 log bsp name lec

[Err] 1222 - The used SELECT statements have a different number of columns 是因為兩個select 語句的查詢元素個數不一致導致的,如SELECT
*
FROM
(
SELECT

province_code,
province_name,
category_code,
category_name,
logic_warehouse_name,
BUSINESS_TYPE AS inputbusiness_type,
order_no AS inputorder_nofrom,
products_nums,
total_amount AS inputtotal_amount,
`status` AS inputstatus,
warehouse_usage,
input_time AS state_time
FROM
es_ctwh_stock_input
WHERE
source_from = ‘CTWH‘
AND PROVINCE_CODE = ‘110000‘
UNION ALL
SELECT
warehouse_usage,
provider_code,
province_name,
business_type AS outputbusiness_type,
order_no AS outputorder_no,
category_code,
category_name,
output_nums,
total_amount AS outputtotal_amount,
provider_code,
provider_name,
`status`,
output_time AS state_time
FROM
es_ctwh_stock_output
WHERE
source_from = ‘CTWH‘
AND province_code = ‘110000‘
) a

UNION ALL 小結