【问题标题】:Selecting data where there's less than 10 linked rows选择链接行少于 10 个的数据
【发布时间】:2015-02-03 23:45:13
【问题描述】:

我在 mySQL 数据库中有 2 个表:

  • 代理ID, host, port, user, pw
  • 帐号proxyID, column

我想获取所有代理的 ID 出现在帐户表 <=10 次。

SELECT count(ProxyId) from Account

不知道如何从这里继续并获取出现小于 10 的 Proxy 值。

【问题讨论】:

  • 好吧,如果您想要这个结果,那么您可能已经尝试过使用 SQL 进行某些操作。请在您的问题中包含这一点。

标签: mysql sql database select


【解决方案1】:
select a.Id from proxy a, account b
where a.ID = b.proxyId
group by a.ID
having count(*) <= 10

【讨论】:

    【解决方案2】:

    试试这样的:

    SELECT p.*
    FROM Proxy AS p JOIN Account AS a ON p.ID = a.proxyID
    GROUP BY p.ID
    HAVING COUNT(*) <= 10
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-18
      • 1970-01-01
      相关资源
      最近更新 更多