-------distinct 去重複查詢數據庫
select * from accounts acc join (select distinct accid from roles) r on r.accid=acc.IDci
-----不須要distinct select * from (select MAX(ID)roleid,accid from roles group by accid) rr join (select * from accounts) acc on acc.ID=rr.accidselect
--------解釋一下不用distinct 去重複查詢語句數據
Select * from (Select max(不重複的字段就行) as roleid,要去重複字段名 From 數據表 Where 條件 Group by 要去重複字段名) as A join 數據庫表 on 條件查詢