关于mysql如何得到排重的记录? 有表tblcreate tbl(id int, rid int, gid int);希望得到表中id, rid不重复的记录,这个select语句如何写呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select * from tb1 a,tb1 b where a.id<>b.id and a.rid<>b.rid; 1楼写错了select id , rid , gid from tb1 group by id,rid select * From tb1 where strcmp(id,rid) <>0 参考下贴中的多种方法http://topic.csdn.net/u/20091231/16/2f268740-391e-40f2-a15e-f243b2c925ab.html[征集]分组取最大N条记录方法征集,及散分.... select * from tbl a where not exists (select 1 from tbl where id=a.id and rid=a.rid and gid >a.gid) 如果对结果没有要求则可以直接select id,rid,gid from tbl group by id,rid select * from(select count(*) as 重复数,id,rid from tbl group by id,rid) where 重复数>1 不好意思,错了select * from(select count(*) as 重复数,id,rid from tbl group by id,rid) where 重复数<=1 mysql过程定义的问题 mysql 数据库中varbinary 字段如何更新 存储过程,帮忙看下错在哪???——急!!!!! 请教这个excel格式的题库是哪个系统导出的,谢谢各位~ ----------第一次用MYSQL,请各位高手帮忙看看这个错误!在线等待!------------- mysql里有沒有級聯﹗ XP下MYSQL如何工作! MySQL数据导入/导出问题 那里有工具将SQL sever的数据库转换成MySQL的??求救啊…… mysql创建event时报错 mysql 存储过程 事务 根据表中部分内容截取,更新其他字段
[征集]分组取最大N条记录方法征集,及散分....
where not exists (select 1 from tbl where id=a.id and rid=a.rid and gid >a.gid)
group by id,rid
select * from(select count(*) as 重复数,id,rid from tbl group by id,rid) where 重复数<=1