I have three tables; Auctions, Auction Offers and Users. The table structure looks something like this:
Auctions: id title -- ----- 1 Auction 1 2 Auction 2 Auction Bids: id user_id auction_id bid_amt -- ------- ---------- ------- 1 1 1 200.00 2 2 1 202.00 3 1 2 100.00
Users is a standard table with an identifier and username.
My goal is to join these tables so that I can get the highest values ββfor these bids and also get the usernames associated with these bids; so I have the result like this:
auction_id auction_title auctionbid_amt user_username ---------- ------------- -------------- ------------- 1 Auction 1 202.00 Bidder2 2 Auction 2 100.00 Bidder1
So far, my request is as follows:
SELECT a.id, a.title, ab.bid_amt, u.display_name FROM auction a LEFT JOIN auctionbid ab ON a.id = ab.auction_id LEFT JOIN users u ON u.id = ab.user_id GROUP BY a.id
This gets the single lines I follow, but seems to display the lowest bid_amt, not the highest.
sql join mysql
Keithamus
source share