如何从多个列中编写count mysql查询。我有uid,这在所有表中都是通用的,所以我把我的查询框成这样它可以完成工作,但是有更好的方法来编写多个count查询吗
SELECT
(SELECT count(*) from follow WHERE followed_user_uid = 'b4eb3820-1fc6-11e8-aead-23ee40fdc27f') as following,
(SELECT count(*) from follow WHERE my_user_uid= 'b4eb3820-1fc6-11e8-aead-23ee40fdc27f') as followers,
SUM(
(SELECT count(*) from prac_test where UID = 'b4eb3820-1fc6-11e8-aead-23ee40fdc27f') +
(select count(*) from multi_test where my_UID = 'b4eb3820-1fc6-11e8-aead-23ee40fdc27f') +
(select count(*) from shadow_test where UID = 'b4eb3820-1fc6-11e8-aead-23ee40fdc27f')
) as totalTestCount;
1条答案
按热度按时间xlpyo6sf1#