自己解决了 还是改了sql写法算了,用UNION ALL来区分从哪个表取的数据,待验证中。。
select '入场' as 出入场类型,car_no,(
CASE
WHEN income_record_cloud.card_type_id = '7' THEN
'员工卡'
WHEN income_record_cloud.card_type_id = '8' THEN
'商户卡'
WHEN income_record_cloud.card_type_id = '11' THEN
'临时车' ELSE '未知车辆类型'
END
) AS 车辆类型,(
CASE
WHEN income_record_cloud.iogate_id BETWEEN '1'
AND '3' THEN
'北门'
WHEN income_record_cloud.iogate_id BETWEEN '4'
AND '6' THEN
'南门'
WHEN income_record_cloud.iogate_id BETWEEN '7'
AND '8' THEN
'西门' ELSE '其他门'
END
) AS 入口
from income_record_cloud
UNION all
select '出场' as 出入场类型,car_no,(CASE
WHEN outcome_record_cloud.card_type_id = '7' THEN
'员工卡'
WHEN outcome_record_cloud.card_type_id = '8' THEN
'商户卡'
WHEN outcome_record_cloud.card_type_id = '11' THEN
'临时车' ELSE '未知车辆类型'
END
) AS 车辆类型,(
CASE
WHEN outcome_record_cloud.iogate_out_id BETWEEN '1'
AND '3' THEN
'北门'
WHEN outcome_record_cloud.iogate_out_id BETWEEN '4'
AND '6' THEN
'南门'
WHEN outcome_record_cloud.iogate_out_id BETWEEN '7'
AND '8' THEN
'西门' ELSE '其他门'
END
) AS 入口 from outcome_record_cloud