【问题标题】:MySQL: How do I merge two count queries?MySQL:如何合并两个计数查询?
【发布时间】:2022-08-04 14:22:55
【问题描述】:

如何将这些查询作为单个查询运行?

SELECT count(url) as t1 from shop_links 

SELECT count(url) as t2 from shop_links where status = 3 

最后我想要 t1 和 t2

    标签: mysql


    【解决方案1】:

    请这样做

    SELECT ((SELECT count(url) as t1 from shop_links) + (SELECT count(url) as t2 from shop_links where status = 3 )) AS count 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-08-14
      • 2015-01-31
      • 1970-01-01
      • 1970-01-01
      • 2013-03-27
      • 1970-01-01
      • 2016-04-10
      相关资源
      最近更新 更多