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 に答える