我有这样的查询:

SELECT price FROM orders WHERE user_id = 10 HAVING count(*) > 1

它有效,但始终仅返回一行。我究竟做错了什么?

最佳答案

SELECT
o.price,
o.user_id
FROM orders o
INNER JOIN(
SELECT
user_id
FROM orders
WHERE
user_id = 10
GROUP BY user_id
HAVING count(*) > 1
) subQ
ON subQ.user_id = o.user_id

关于mysql - MySQL问题与HAVING,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20124446/

10-12 05:43