-- 根据表的一个字段id,关联查询出其他字段,并赋值给新表
UPDATE report_container_transportation a,base_line b,base_station c set a.line_name =
CONCAT(if(b.go_or_back =1 ,'WB','EB'),c.cn_name)
WHERE a.create_date > '20190421' and a.line_id = b.id and b.destination_station_id = c.id
-- 查询一个表一列相同另一列不同的数据
SELECT a.train_id,b.train_id,a.remarks,b.remarks
FROM report_container_transportation a
left join report_container_transportation b on a.train_id = b.train_id
WHERE a.create_date > '20190421' and a.remarks != b.remarks GROUP BY a.train_id