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 |
|
godspeedba
Yak Posting Veteran
90 Posts |
Posted - 2009-04-20 : 10:01:55
|
| Hello FriendsI have a Select call that needs to grab the name of the country, but only if it is specified. I started with this:SELECT tb_feature_basket.*, tb_country.country_name, from tb_feature_basket, tb_country Inner join tb_country on tb_feature_basket.basket_country = tb_country.countryid WHERE tb_feature_basket.basket_property = @bnbid and tb_feature_basket.basket_country = tb_country.countryid The problem I have, if the tb_feature_basket.country is '0' then it won't locate the country_name as there isn't one in the table.Because of this it won't return any rows. When Ultimately is has to return all the rows and the country name but only if it has one. |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-04-20 : 10:06:17
|
| Try thisSELECT tb_feature_basket.*, tb_country.country_name, from tb_feature_basket, tb_country left join tb_country on tb_feature_basket.basket_country = tb_country.countryid and tb_feature_basket.basket_property = @bnbid MadhivananFailing to plan is Planning to fail |
 |
|
|
godspeedba
Yak Posting Veteran
90 Posts |
Posted - 2009-04-20 : 10:18:07
|
| Many thanks Madhivanan, works perfectly. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-04-20 : 10:20:49
|
quote: Originally posted by godspeedba Many thanks Madhivanan, works perfectly.
You are welcome MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|