作者热门文章
- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
这是我的问题。它从两个数据库的两个表中选择一个 id 列表。查询工作正常。
select en.id, fp.blogid
from french.blog_pics fp, french.blog_news fn, english.blog_news en
where fp.blogid = fn.id
and en.title_fr = fn.title
and fp.title != ''
我只想显示 en.id
多次出现的行
例如,如果这是当前的查询结果
en.id fp.blogid
---------------
10 12
12 8
17 9
12 8
我只想查询来显示这个
en.id fp.blogid occurrences
-----------------------------
12 8 2
最佳答案
select en.id, fp.blogid, count(*) as occurrences
from french.blog_pics fp, french.blog_news fn, english.blog_news en
where fp.blogid = fn.id
and en.title_fr = fn.title
and fp.title != ''
group by en.id
having count(*) > 1
关于MySQL:选择出现不止一次的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4242990/
我是一名优秀的程序员,十分优秀!