How can I exclude a user with a specific id in MySQL
How can I exclude a user with a user_id of 1 for example from the following query below?
Here is My MySQL code.
"SELECT users.*, COUNT(*) as coun, users_comments.user_id
FROM users_comments
INNER JOIN users ON users_comments.user_id = users.user_id
GROUP BY users_comments.user_id
ORDER BY coun DES开发者_运维百科C
LIMIT 5"
SELECT users.*, COUNT(*) as coun, users_comments.user_id
FROM users_comments
INNER JOIN users ON users_comments.user_id = users.user_id
WHERE users.user_id != 1 <---------------
GROUP BY users_comments.user_id
ORDER BY coun DESC
LIMIT 5
SELECT users.*, COUNT(*) as coun, users_comments.user_id
FROM users_comments
JOIN users ON users_comments.user_id = users.user_id
WHERE users.user_id not in(1,3)
GROUP BY users_comments.user_id
ORDER BY coun DESC
LIMIT 0,5
精彩评论