我創建了一個表幫助下結構 -需要一個SQL查詢
$sql = "CREATE TABLE followers
(
uid int UNSIGNED NOT NULL UNIQUE,
PRIMARY KEY(uid),
follower_count int UNSIGNED ,
is_my_friend bool,
status_count int UNSIGNED,
location varchar(50)
)";
我需要找到的人,最大的UID(status_count + FOLLOWER_COUNT),其is_my_friend = 1
我寫了下面的查詢,但我沒有得到正確的用戶名。
SELECT p.uid FROM (select uid,is_my_friend,max(follower_count+status_count) from followers) p WHERE p.is_my_friend = 1;
如果有什麼是相同的最大一個以上的用戶? – 2010-04-19 11:41:42
@Mark:好的...我的代碼可以處理 – Bruce 2010-04-19 11:43:40