首页 > 一个sql语句的写法

一个sql语句的写法

我在写排序的时候要对两个字段进行排序
这两个字段分别为 uid和blogid
uid和blogid 是通过点赞方式绑定的,因为之前没有进行判断一个人可以点多次,现在要对数据进行修正,请问
如何能够得到以下意图得到 同一个人对同一篇博客多次点赞的数据

如果用错误的sql语句来表达我的意思的话应该这样写
select count (id) as num group by uid,blogid having num>1
请大家指教


select t1.* from table1 t1 right join
(select * from
(select uid, blogid, count(id) as num from table1 group by uid, blogid) as t 
where t.num > 1) t2 
on t1.uid = t2.uid and t1.blogid = t2.blogid

count(*) 改成 count(1) 效果更佳

【热门文章】
【热门文章】