MySQL Forums
Forum List  »  Newbie

Re: Merging the results of multiple tables
Posted by: Mike Clemens
Date: March 25, 2005 06:51PM

Usually I do this sort of thing outside of the database: you could probably do it using a temporary table to hold the names, and then run a series of updates to populate it with song titles. That's a lot of thrashing around in your tables, though.

The quickest sort of merge I can think of is to display the count of songs available, and then allow the user to navigate through to a list of songs for that user:

SELECT user, CONCAT(COUNT(songs)," songs uploaded")
FROM Songs
GROUP BY user
ORDER BY user

So you would get a result like:

Bob 3 songs uploaded
Joe 2 songs uploaded
Sam 10 songs uploaded
Jane 3 songs uploaded

"Flattening" a relational structure like this is best done outside of SQL in my experience, but that's mainly because I haven't found a clean way to do it. ;-)

Options: ReplyQuote


Subject
Written By
Posted
Re: Merging the results of multiple tables
March 25, 2005 06:51PM


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.