用户编号 姓名 角色 模块代码 模块名称
0000 A 系统管理员 01 生产管理
0000 A 系统管理员 02 库存管理
0000 A 系统管理员 03 采购管理
0000 A 系统管理员 04 销售管理
0000 A 系统管理员 05 系统管理
0000 A 操作员 05 系统管理如何在用select查询的时候把最后两条重复的,去掉一条, 最后两条角色虽然不同,但 模块相同
0000 A 系统管理员 01 生产管理
0000 A 系统管理员 02 库存管理
0000 A 系统管理员 03 采购管理
0000 A 系统管理员 04 销售管理
0000 A 系统管理员 05 系统管理
0000 A 操作员 05 系统管理如何在用select查询的时候把最后两条重复的,去掉一条, 最后两条角色虽然不同,但 模块相同
FROM tables
(select 模块名称,max(角色) from tb group by 模块名称) n
where m.模块名称=n.模块名称 and m.角色 = n.角色max那个地方用min也行.
select max(用户编号) as 用户编号,
max(姓名) as 姓名,
max(角色) as 角色,
max(模块代码) as 模块代码,
模块名称
from tbName group by 模块名称
insert T select '0000', 'A', '系统管理员', '01', '生产管理'
union all select '0000', 'A', '系统管理员', '02', '库存管理'
union all select '0000', 'A', '系统管理员', '03', '采购管理'
union all select '0000', 'A', '系统管理员', '04', '销售管理'
union all select '0000', 'A', '系统管理员', '05', '系统管理'
union all select '0000', 'A', '操作员', '05', '系统管理'select max(用户编号) as 用户编号,
max(姓名) as 姓名,
max(角色) as 角色,
max(模块代码) as 模块代码,
模块名称
from T group by 模块名称
order by 模块代码--result
用户编号 姓名 角色 模块代码 模块名称
---- ---- ---------- ---- ----------
0000 A 系统管理员 01 生产管理
0000 A 系统管理员 02 库存管理
0000 A 系统管理员 03 采购管理
0000 A 系统管理员 04 销售管理
0000 A 系统管理员 05 系统管理(5 row(s) affected)