mysql 查询问题 谢谢大家 id name1 a2 b3 b4 c我想要查询不重复的记录怎么查询?也就是 查出来的结果是id (1,4) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 本帖最后由 ACMAIN_CHM 于 2012-01-09 13:04:48 编辑 select * from table1 a where not exists (select 1 from table1 where name = a.name) SELECT MAX(id) FROM table1 GROUP BY name HAVING COUNT(*)=1 select id from t group by name having count(*) = 1; select * from table a where not exists (select 1 from table1 where a.name=name) select id,name,count(name) a from tableNamegroup by namehaving a=1这样的主要问题是你的数据多吗?name有没有索引,不然可能效率会有影响。 liuxinran819此好汉,方法较好,绿色且速度快。洒家顶之。 select * from t group by name having count(*) = 1; 使用命令将文本文件“*.txt”装载到数据库表中的问题 怎么卸载MySQL? 遇到个数据库查询的问题,发来大家讨论下 :) 请问一个sql查询,三表查询 Linux 下载 MySQL 服务器启动成功,可是登陆不成功,大侠帮忙!! 请问关于join语法的问题 【投票】你是如何备份你线上MySQL服务器? 大家帮帮忙!php与mysql连接的问题 如何用C++对mysql中的blob字段进行操作 mysql 同一条sql每次查询时间不一样? mysql 存储过程该如何处理存储过程返回的多结果集 救命!!Mysql把数据转换为大写
where not exists (select 1 from table1 where a.name=name)
from tableName
group by name
having a=1
这样的主要问题是你的数据多吗?name有没有索引,不然可能效率会有影响。
此好汉,方法较好,绿色且速度快。洒家顶之。