我有兩個sql查詢。我想知道如何將兩個查詢合併爲一個。在MySQL中使用子查詢進行選擇
// query #1 - Using this query return totalpoints of specific user ex :userId (10234324234)
SELECT SUM(points) AS totalPoints FROM users_points WHERE user_fb_id =10234324234 AND match_id >= 2
//query #2 - Using this query will return all the records on specific condition
SELECT users_points.*, user_points.totalPoints, user.user_firstName FROM users_points INNER JOIN user ON users_points.user_fb_id = user.user_fb_id WHERE users_points.match_id >= '$matchId'
我想獲取記錄,所有的用戶記錄與每個用戶的totalPoints使用一個查詢。
http://dev.mysql.com/doc/refman/5.0 /en/subqueries.html – Scuzzy
@Scuzzy我嘗試了幾種方法。但我不能那樣做。你可以評論相關的查詢或一個例子 –