MySQL Forums :: Newbie :: limiting rows returned


Advanced Search

limiting rows returned
Posted by: Jim Swarts ()
Date: September 07, 2009 01:26PM

I have the following MYSQL query:

select c.*, username as bidder from phpbb_auction_bids c, phpbb_users d where c.bid_user_id = d.user_id order by bid_auction_number, bid_number desc

It returns these rows:

"bid_number","bid_auction_number","bid_user_id","bid_time","bid_amount","bidder"
342,330,152,30,20.00,"bobbleboy"
335,330,20,5,15.00,"jarkbark"
332,330,152,4,10.00,"bobbleboy"
331,330,47,2,6.00,"kevinbuddha"
330,330,20,1,5.00,"jarkbark"
333,331,63,2,25.00,"ShoMeNodder"
336,332,324,8,65.00,"FunkoFanJim"
334,332,63,3,50.00,"ShoMeNodder"
339,333,63,24,35.00,"ShoMeNodder"
338,333,152,23,11.00,"bobbleboy"
337,333,47,22,10.00,"kevinbuddha"
341,335,324,27,125.00,"FunkoFanJim"
340,335,63,26,100.00,"ShoMeNodder"

For each bid_auction_number I only want the highest corresponding bid_number, thus giving these results:

"bid_number","bid_auction_number","bid_user_id","bid_time","bid_amount","bidder"
342,330,152,30,20.00,"bobbleboy"
333,331,63,2,25.00,"ShoMeNodder"
336,332,324,8,65.00,"FunkoFanJim"
339,333,63,24,35.00,"ShoMeNodder"
341,335,324,27,125.00,"FunkoFanJim"

How do I modify my query to achieve this?



Edited 1 time(s). Last edit at 09/07/2009 01:56PM by Jim Swarts.

Options: ReplyQuote


Subject Written By Posted
limiting rows returned Jim Swarts 09/07/2009 01:26PM
Re: limiting rows returned Pavel Leonov 09/07/2009 02:22PM
Re: limiting rows returned laptop alias 09/07/2009 02:36PM
Re: limiting rows returned Pavel Leonov 09/08/2009 01:12AM
Re: limiting rows returned laptop alias 09/08/2009 01:38AM
Re: limiting rows returned Pavel Leonov 09/08/2009 02:37AM
Re: limiting rows returned Jim Swarts 09/07/2009 05:21PM
Re: limiting rows returned Rick James 09/07/2009 06:04PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.