首页 > 代码库 > 多表关联时视图查出重复数据问题

多表关联时视图查出重复数据问题

多表关联时本身有一条数据,但是视图查出重复数据用distinct可以解决。

如: 

视图如下

SELECT DISTINCT
t1.station_id as station_id,
t1.tick_sn as tick_sn,
t1.order_id as order_id,
t2.station_name as station_name,
t3.game_id as game_id,

FROM
electric_lottery_report_info t1
LEFT JOIN electric_lottery_station_info t2
ON t1.station_id = t2.station_id
LEFT JOIN electric_lottery_param_info t3
ON t1.game_id = t3.game_id

多表关联时视图查出重复数据问题