-1

I'm stuck on this problem, let me explain. I have two table one called league that have this structure:

id|leagueCode|Country|League
0 | B1       |Germany|Bundesliga
1 | I1       | Italy |Serie A

another table called soccerseason have this structure:

id|caption   |League |years
 0|Bundesliga|B1     |2014
 1| Serie A  |   I1  |2014

Now, I want eet the league values from the League table. In particular Bundesliga and Serie A. How you can see in the soccerseason table each value have a years, so I want select Bundesliga for the year 2014 and Nation Germany. Because my app, have this selection structure:

Select year: 2014 Select nation: Germany

I'm aspect a result like this: Bundesliga

How I can achieve this?

Salvatore Fucito
  • 255
  • 1
  • 14
  • I'm just glad that I don't have to work with this insane structure – Strawberry Aug 16 '15 at 17:56
  • Please use the search before posting a new question. Especially if you have the feeling that the answer is more or less trivial, there is a high chance that existing Q&A material already eixsts on site. If you only find existing material that is only close but does not answer your question, please reference it and explain how your question is different to it and why it didn't make it for your case. – hakre Aug 16 '15 at 18:07
  • Salvatore sometimes we don't sugar coat things here. It was a fun loving comment from @Strawberry, unlike yours. So do yourself a favor, and delete it. – Drew Aug 16 '15 at 18:38

1 Answers1

0

You will need to join the tables together using a column that exists in both tables. From your example, I am guessing soccerseason.League is the same as league.leagueCode, in which case you can join the tables using this column, and return the results as follows:

SELECT *
FROM league l
LEFT JOIN soccerseason s ON (s.League = l.leagueCode)
MaggsWeb
  • 3,018
  • 1
  • 13
  • 23