SQL queries are still my weakest point, so here I am with yet another SQL question.
Imagine I have two tables: auctions and bids. Table auctions contains my auctions and table bids contains the list of bids for each auction.
Now I'm selecting values like this:
SELECT
`auction_title`,
`auction_seo_title`,
`auction_description_1`,
`auction_unixtime_expiration`,
`auction_startPrice`,
MAX(`bids`.`bid_price`) as `bid_price`
FROM
`auctions`
LEFT JOIN `bids` ON `auctions`.`auction_id`=`bids`.`bid_belongs_to_auction`
ORDER BY
`auction_unixtime_expiration`
ASC
LIMIT 5
The query works, but it's got a little catch to it: It selects only those auctions, which have at least one corresponding value inside the bids table. That means that if I have a new auction, which has no bids yet, the query doesn't return this auction, but I want it too!
I believe this is a very simple problem for anyone with at least above average SQL skills. I hope someone like that comes around :) Thanks in advance!
LIMIT...did u try it withoutLIMITor you should try withRIGHT JOINGROUP BYclause.LEFT JOIN- you have to get all auctions as a result with bids related to it or padded with nulls. So look carefully one more time ;-)LEFT JOIN,INNER JOINandRIGHT JOIN, no change. Also,LIMITis not a problem, I have got only 3 auctions in testing, so 5 isn't changing anything.GROUP BY bids.bid_belongs_to_auctionin your query... Also,LIMITapplies to all rows, so if you have 3 auctions with 10 bids each, the query will only return 1 auction with 5 bid rows.