SELECT * FROM `name`;
-- 查询出三条 去除了重复的
select distinct name from name;
-- 会查询出五条 其实是distinct(name,id)
select distinct name,id from name;
-- 报错 distinct必须放在头部
select id,DISTINCT name from name;
如果要查询不重复的记录,有时候也可以用group by :
select id,name from user group by name;
distinct有些浪费资源,使用group by比distinct都要好!