Small problem with SQL query with SELECT

SQL queries are still my weakest point, so I have another SQL question.

Imagine that I have two tables: auctions and bids . Table auctions contain my auctions and tables containing a list of offers for each auction.

Now I select these values:

   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 request works, but he caught it a little: he selects only those auctions that have at least one corresponding value in the bid table . This means that if I have a new auction that does not yet have bids, the request does not return this auction, but I want it too!

, , , , SQL. , - :) !

+3
1
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`
GROUP BY `auction_id`
ORDER BY `auction_unixtime_expiration` ASC

. , , LIMIT .

+1

All Articles