If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > MySQL query to get multiple comma seperated values of a single column from join table

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-04-11, 12:56
earnathome earnathome is offline
Registered User
 
Join Date: Oct 2011
Posts: 1
Question MySQL query to get multiple comma seperated values of a single column from join table

Please refere below table. First table is 'Schedule' which has comma seperated team ids (e.g. 1,2). I want to create a single query to fetch team names from joined Team table. Is it possible?

Schedule
------------
Id date teams
1 2010-01-15 1,2
2 2010-01-17 3,4

Team
--------
id team
1 England
2 South Africa
3 Sri Lank
4 India

Thanks.
Reply With Quote
  #2 (permalink)  
Old 10-05-11, 02:32
it-iss.com it-iss.com is offline
Registered User
 
Join Date: Sep 2009
Location: San Sebastian, Spain
Posts: 620
Nothing is impossible but you have made your life very complicated by storing the information in the schedule table in this way. You should have a look at changing the schedule table to include a column for home team and away team.

To continue with your setup now have a look at the function SUBSTRING_INDEX to get each value that you are looking for.
__________________
Ronan Cashell
Senior Oracle/MySQL DBA
http://www.it-iss.com
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On