代码改变世界

sql语句查询出数据重复,取唯一数据

2016-04-07 13:43  sihao560  阅读(2253)  评论(0编辑  收藏  举报
select distinct mr.id,ifnull(mr.pid,0) as pid,mr.name
from sys_role_res srr
left join main_res mr on mr.id=srr.res_id
left join sys_role sr on sr.id=srr.role_id
left join bas_member_role bmr on bmr.role_id=sr.id
left join bas_member bm on bmr.member_id=bm.id
where bm.id = 4
and mr.is_delete = 0
and ifnull(mr.permission,0) = 0
order by mr.id

select distinct 查询值name from 表 where 条件