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
Difficult if you want to do it only in SQL. If you had designed the table right: Schedule ------------ Id date team1 team2 it would be a lot easier.
Hi Rukbat, Thanks for your response. Can you please guide me a query to fetch team1 and team2 in a single query as per your design. Thanks in advance.
something like select team.name from team, schedule where team.id = schedule.team1 or team.id = schedule.team2 You'll get two records anyway.