gpt4 book ai didi

mysql - mysql中查找重复项

转载 作者:行者123 更新时间:2023-11-29 14:18:11 25 4
gpt4 key购买 nike

SELECT COUNT(organization.ID)
FROM organization
WHERE organization.NAME IN (
SELECT organization.NAME
FROM organization
WHERE organization.NAME <> ''
AND organization.APPROVED = 0
AND organization.CREATED_AT > '2012-07-31 04:31:08'
GROUP BY organization.NAME
HAVING COUNT(organization.ID) > 1
)

此查询发现重复项,问题是由于内部语句,页面加载需要 6 秒。有没有办法让它跑得更快? MySQL 数据库版本 5.1。

最佳答案

是的。这很慢,因为 MySQL 处理“in”查询的速度很慢。您可以使用以下方法来修复它:

SELECT COUNT(organization.ID)
FROM organization o
WHERE exists (
SELECT organization.NAME
FROM organization o2
WHERE organization.NAME <> ''
AND organization.APPROVED = 0
AND organization.CREATED_AT > '2012-07-31 04:31:08' and
organization.name = o.organization.name
GROUP BY organization.NAME
HAVING COUNT(organization.ID) > 1
)

关于mysql - mysql中查找重复项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12222239/

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