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 |
|
ConfusedAgain
Yak Posting Veteran
82 Posts |
Posted - 2011-04-20 : 06:06:10
|
| Well it seems when the field is blank.I have two tables I want to join by two field in each table.Field 1 and Field 1 in each table link fine with say an ID number 200Field 2 in one table is NULL when I look at the table in the query and Field 2 in the other table is "". So these records do not link. Neither table has anything in the Default or Binding property of that field in the table. My question is how can I get table two to always default to NULL if no record is entered in that table? |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2011-04-20 : 06:16:08
|
If no record (better say row) is entered in that table then there is no row and if there is no row then there is no default in any column because there is no row. No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
ConfusedAgain
Yak Posting Veteran
82 Posts |
Posted - 2011-04-20 : 06:42:55
|
| There is a row generated and the Field1 in each table = 200 it is field2 that they dont match where one is saying NULL and the other is ""Hopefully that makes more sense |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2011-04-20 : 06:50:09
|
If you need a quick way to get your join working then use this:on table1.column1 = table2.column1 and coalesce(table1.column2,'') = coalesce(table2.column2,'') Otherwise post the create statements of your tables. No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
lionofdezert
Aged Yak Warrior
885 Posts |
Posted - 2011-04-20 : 06:51:10
|
| if any of joining column may contain NULL values then you must use ISNULL(columnName,'')SELECT column1,column2, column3FROM table1 INNER JOIN table2ON ISNULL(table1.column1,'') = ISNULL(table2.column1,'')--------------------------http://connectsql.blogspot.com/ |
 |
|
|
ConfusedAgain
Yak Posting Veteran
82 Posts |
Posted - 2011-04-20 : 07:27:43
|
| ON ISNULL(table1.column1,'') = ISNULL(table2.column1,'')works like clockworkMagic,many thanks |
 |
|
|
|
|
|
|
|