astralaaron Posted September 19, 2010 Share Posted September 19, 2010 Hello, i have run into a situation similar to this:Multiple users post their products into this database. On the home page of this site, there is a search. When searched, currently all of the products from all of the users (including some user information joined from a separate table.) It works great, except now i am required to change it from posting 'all products' from 'all users' to only '3 products' from 'each user who has relevant products' which can be clicked on to view all, etc.__So i am trying to find out this:-Can you use LIMIT somehow to not return 3 total results, but instead 3 from each user?-Or would I need to first call the database and return all of the different users who have relevant products, then loop through and query the database for each one and LIMIT 3?I am just trying to find an efficient way to make it happen, because it could potentially be pretty big. Link to comment Share on other sites More sharing options...
astralaaron Posted September 19, 2010 Author Share Posted September 19, 2010 I found this website which has really useful information on the topic:http://www.xaprb.com/blog/2006/12/07/how-t...r-group-in-sql/I found the UNION ALL to work the best for my situation Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.