rootnik
11-20-2008, 03:28 PM
Let's say I have a table in my database that stores my user's favorite movies. Each row in the table stores a single movie, so the user can have multiple rows in the movie table.
Now I want to display a list of users that are on your friend list and ALSO display what movies each friend has in the database.
Is this possible with 1 query, or am I going to have to get the list of friends first and then perform a separate query for each friend to find out what movies they have 'favorited'?
--------------- Added 1227203636 at 1227203636 ---------------
I believe I found my answer here:
http://www.mysqlperformanceblog.com/2006/09/04/group_concat-useful-group-by-extension/
After some tests it seems that if you are working with 2 large tables you may as well write separate queries. I have 2 tables with over 50,000 rows in each and it takes over 20 seconds to complete the query. This is a good example of less queries not always equaling faster execution.
Now I want to display a list of users that are on your friend list and ALSO display what movies each friend has in the database.
Is this possible with 1 query, or am I going to have to get the list of friends first and then perform a separate query for each friend to find out what movies they have 'favorited'?
--------------- Added 1227203636 at 1227203636 ---------------
I believe I found my answer here:
http://www.mysqlperformanceblog.com/2006/09/04/group_concat-useful-group-by-extension/
After some tests it seems that if you are working with 2 large tables you may as well write separate queries. I have 2 tables with over 50,000 rows in each and it takes over 20 seconds to complete the query. This is a good example of less queries not always equaling faster execution.