Solved

Help required writing join query

Posted on 2013-05-23
1
249 Views
Last Modified: 2013-06-08
I need to get name(of a collection) from Table1 and name of all the songs in that collection from table 3 . Table 2 is the connection between table 1 and table 3. music_playlist_id connects table 2 to table 1. tbl_content_common_id connects table 2 with table 3.

Table 1

CREATE TABLE IF NOT EXISTS `music_playlists` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `name` varchar(50) NOT NULL,
  `collection_id` int(10) NOT NULL,
  PRIMARY KEY (`id`)
)

Open in new window


Table 2

CREATE TABLE IF NOT EXISTS `playlist_song_mappings` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `music_playlist_id` int(11) NOT NULL,
  `tbl_content_common_id` int(11) NOT NULL,
  PRIMARY KEY (`id`)
)

Open in new window



Table 3

CREATE TABLE IF NOT EXISTS `tbl_content_commons` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `content_common_code` varchar(20) CHARACTER SET utf8 NOT NULL,
  `content_common_name` varchar(100) CHARACTER SET utf8 NOT NULL
)

Open in new window


Any help is much appreciated
0
Comment
Question by:Sreejith22
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 250 total points
ID: 39190506
SELECT m.[name] AS CollectionName, c.content_common_name
FROM music_playlists m INNER JOIN
    playlist_song_mappings p ON m.collection_id = p.music_playlist_id INNER JOIN
    tbl_content_commons c ON p.tbl_content_common_id = c.id
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question