gpt4 book ai didi

mysql - 如何在 MySQL 中排除具有特定 ID 的用户

转载 作者:行者123 更新时间:2023-11-29 05:44:44 24 4
gpt4 key购买 nike

例如,如何从以下查询中排除 user_id 为 1 的用户?

这是我的 MySQL 代码。

"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 DESC
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

关于mysql - 如何在 MySQL 中排除具有特定 ID 的用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3378132/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com