0

I need to join two tables and get the output as i stated below, enter image description here

Here my problem is I couldn't inner join the two tables and get the output since it refers the same column name for team1 and team2 (Which will look like "select ct.teamname,ct2.teamname from clm_schedule cs" where it gives me an error). I can do it in two separate queries like below,

select ct.teamname as team1 from clm_schedule cs inner join clm_team ct on ct.teamid = cs.team1

select ct2.teamname as team2 from clm_schedule cs2 inner join clm_team ct2 on ct2.teamid = cs2.team2

But I couldn't join it to get a single resultset. Please suggest me a way.

1 Answer 1

2

You should be able to do this:

SELECT ct1.teamname as team1 ,ct2.teamname as team2 
FROM clm_schedule cs 
LEFT JOIN clm_team AS ct1 
  ON ct1.teamid = cs.team1
LEFT JOIN clm_team AS ct2
  ON ct2.teamid = cs.team2;
2
  • AgRizzo, I think you are right, but on the last line it should be "cs.team2" right? Oct 3, 2013 at 18:11
  • hehe :D thanks.. tried to edit it on your answer but it doesn't allow me to i guess Oct 3, 2013 at 18:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.