gpt4 book ai didi

MySQL:选择出现不止一次的行

转载 作者:IT老高 更新时间:2023-10-28 23:50:25 25 4
gpt4 key购买 nike

这是我的问题。它从两个数据库的两个表中选择一个 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com