Was "individual queries to each table" a typo? Are you dealing with a single, or several tables? I'm guessing you mean a single table.
I can't think of any way to do that in a single query, though you might save a few by first fetching all the IDs, preselecting 5 per category_id, then doing a straight select on those. Not very elegant, though. Don't forget to cache the result if that's an option. I suppose you could create a view, but where's the Cake fun in that? On Mon, Mar 2, 2009 at 2:16 AM, jwerd <[email protected]> wrote: > > I have a that associates a category_id, and I need to select 5 rows > per category_id (we'll assume 1,2,3,4,5,6,7) so I need 5 from each > category_id... > > How can I pull this off in CakePHP? The only way I can think is to do > individual queries to each table but that is not only going to put a > big load on the database, it's just an ugly approach in my opinion > > Thanks in advance. :) > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
