参考:https://www.cnblogs.com/tufujie/p/9413852.html https://www.cnblogs.com/bianxj/articles/12367919.html
示例:
EXPLAIN SELECT
`aw`.`order_code` AS `order_code`,
`aw`.`user_id` AS `user_id`,
`aw`.`order_price` AS `total_amount`,
`aw`.`order_price` AS `pay_amount`,
1 AS `order_status`,
1 AS `order_status`,
`aw`.`create_time` AS `create_time`
FROM
`app_weigh_data` `aw`
LEFT JOIN `app_order` `ao` ON concat(`aw`.`order_code`) = `ao`.`order_code`
两张表数据类型不一致 app_order表 order_code 是utf-8 ,但是 app_weigh_data 的 order_code 是 utf-8mb4
sql查询
SELECT
`app_order`.`order_code` AS `order_code`,
`app_order`.`user_id` AS `user_id`,
`app_order`.`total_amount` AS `total_amount`,
`app_order`.`pay_amount` AS `pay_amount`,
`app_order`.`pay_type` AS `pay_type`,
`app_order`.`order_status` AS `order_status`,
`app_order`.`create_time` AS `create_time`
FROM
`app_order` UNION
SELECT
`aw`.`order_code` AS `order_code`,
`aw`.`user_id` AS `user_id`,
`aw`.`order_price` AS `total_amount`,
`aw`.`order_price` AS `pay_amount`,
1 AS `order_status`,
1 AS `order_status`,
`aw`.`create_time` AS `create_time`
FROM
`app_weigh_data` `aw`
LEFT JOIN `app_order` `ao` ON concat(`aw`.`order_code`) = `ao`.`order_code`
如何处理?
答: 把两张表的 order_code 数据类型改成一样的 ,utf-8