Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
jarv
Posting Yak Master
131 Posts |
Posted - 2014-02-03 : 06:32:13
|
Hi, in my database I have 2 tables I'd like to join.Countries and FixturesCountries = Countryid, countrynameFixtures = teama, teambI have a Countryid for teama and teamb and could like to display the countrynamethis is what I tried:SELECT *FROM wc_fixturesINNER JOIN wc_countriesON wc_fixtures.countrya=wc_countries.countryidAND wc_fixtures.countryb=wc_countries.countryid nothing came back?!Fixtures: Countries: |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2014-02-03 : 06:42:45
|
you should join it twiceSELECT f.*,c1.country as countrya,c2.country as countrybFROM wc_fixtures fINNER JOIN wc_countries c1ON f.countrya=c1.countryidINNER JOIN wc_countries c2ON f.countryb=c2.countryid ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
 |
|
jarv
Posting Yak Master
131 Posts |
Posted - 2014-02-03 : 07:14:18
|
thank you so much! |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2014-02-03 : 13:40:54
|
welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
 |
|
|
|
|