比方說,我有以下表結構:是否有可能在同一個查詢來算兩列
t1
-------------
id // row id
userID_follower // this user is a follows another member
userID_following // other member that this user
是否有可能運行一個查詢到以下兩者結合:
有多少用戶這個人以下從T1 WHERE userID_follower =
SELECT COUNT(ID) 「$身份識別碼。」 。 「
多少用戶遵循從T1這個人
SELECT COUNT(ID),其中userID_following =」 $身份識別碼。」
感謝。
我的天啊。這給了子集數量很多的優點,而不需要通過where子句來篩選整個選擇。非常感謝! – C4u 2015-12-01 15:03:24
你爲什麼需要where子句? – 2017-09-07 19:11:58
@IstiaqueAhmed列應該被索引。不需要進行全表掃描。 – 2017-09-08 08:05:56