0

我有这个 mysql 代码女巫工作得很好

SELECT uid , MAX(value) AS bidvalue FROM auction 
WHERE pid = '$pid' and max_bid=0 
GROUP BY uid 
ORDER BY bidvalue DESC 
LIMIT 1

如何在 users.id=auction.uid 上的用户表中加入此选择?

谢谢

4

2 回答 2

1

我在这里看不到任何魔法:

SELECT uid, users.name, MAX(value) AS bidvalue
FROM auction 
INNER JOIN users ON users.id = auction.uid
WHERE pid = '$pid' and max_bid=0 
GROUP BY uid 
ORDER BY bidvalue DESC 
LIMIT 1
于 2012-09-23T06:39:19.710 回答
1

您可以使用连接,您的查询可能看起来像

SELECT uid, users.name, MAX(value) AS bidvalue
FROM auction 
INNER JOIN users ON users.id = auction.uid
WHERE pid = '$pid' and max_bid=0 
GROUP BY uid 
ORDER BY bidvalue DESC 
LIMIT 1

或者

SELECT uid, users.name, MAX(value) AS bidvalue
FROM auction 
OUTER JOIN users ON users.id = auction.uid
WHERE pid = '$pid' and max_bid=0 
GROUP BY uid 
ORDER BY bidvalue DESC 
LIMIT 1

根据您的需要加入详细信息

于 2012-09-23T06:46:52.413 回答