From an efficiency stand point, I would be cautious using the sub queries.
They can be really, really slow and often times the same results can be found an alternate way.
-Bradly On 1/19/07, Patrick Crowley <[EMAIL PROTECTED]> wrote:
If I can offload the calculations to MySQL, I'd be happy. This works for MySQL 4: SELECT MAX( amount ) FROM `bids` WHERE proxy !=1 GROUP BY item_id ...and then I'd need to total the amounts from each item. But, with subquery support in MySQL 5, I can do this: SELECT SUM(amount) FROM bids WHERE amount = ANY (SELECT MAX(amount) as amount FROM bids WHERE proxy !=1 GROUP BY item_id) That gets me the total raised straight out of the db. :) -- Patrick On Jan 19, 2007, at 10:57 am, Chris Abad wrote: > SELECT * FROM bids WHERE proxy != 1 ORDER BY amount DESC, time DESC > > .. then do your sorting by item in Ruby. guess you could benchmark > it to see which way is faster. not sure if that's what you were > looking for... > > On Jan 19, 2007, at 10:54 AM, Patrick Crowley wrote: > >> SELECT * FROM bids WHERE (item_id = 1 AND proxy != 1) ORDER BY >> amount DESC, time DESC > > _______________________________________________ > Sdruby mailing list > [email protected] > http://lists.sdruby.com/mailman/listinfo/sdruby _______________________________________________ Sdruby mailing list [email protected] http://lists.sdruby.com/mailman/listinfo/sdruby
_______________________________________________ Sdruby mailing list [email protected] http://lists.sdruby.com/mailman/listinfo/sdruby
