Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2011

    Question Unanswered: 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?

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

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


  2. #2
    Join Date
    Sep 2009
    San Sebastian, Spain
    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
    Certified Oracle DBA/Certified MySQL Expert (DBA & Cluster DBA)
    Follow me on Twitter

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts