Hello!I have 2 Tables I want to join:Table1:date_a date_b age name01.01.2000 02.01.2013 23 Nick01.01.1999 02.01.2011 42 Mark02.03.2004 02.01.2013 12 John01.01.2000 01.01.2001 32 Lisa01.04.2002 02.03.2004 12 Mary01.01.2000 02.01.2013 11 Gina
date_a is smalldatetimedate_b is smalldatetimeTable2:date_a days office01.01.2000 4750 A01.01.1999 4384 B02.03.2004 3228 C01.01.2000 366 D01.04.2002 701 E
date_a is smalldatetimedays is int and office is real(not here but in my sample
)the colum "days" has the following relationship:date_a+days=date_bafter the joining i want to get the following table:date_a date_b age name office01.01.2000 02.01.2013 23 Nick A01.01.1999 02.01.2011 42 Mark B02.03.2004 02.01.2013 12 John C01.01.2000 01.01.2001 32 Lisa D01.04.2002 02.03.2004 12 Mary E01.01.2000 02.01.2013 11 Gina A
so I want to match this 2 tables by using 2 colums as "primary key".I tried the folowing:select d1.date_a,d1.date_b, d2.office fromtable_1 d1join table_2 d2 on d1.date_a=d2.date_a AND dateadd(day,d2.days,d2.date_a)=d1.date_a
WIth this code SQL is joining succesfully but the colum d2.office (or any other colum of table_2 after joining with table_01) have just the values 'NULL' (i have a german version, maybe in an english version it is "ZERO").Then I tried the following codes:select d1.date_a,d1.date_b, d2.office fromtable_1 d1,table_2 d2WHERE d1.date_a=d2.date_a AND dateadd(day,d2.days,d2.datue_a)=d1.date_a
same result.and also this one ( i tried to merge both colums to 1 primary key):select d1.date_a,d1.date_b, d2.office fromtable_1 d1join table_2 d2 on cast(d1.date_a as char)+cast(d2.date_a as char)=cast(d2.date_a as char)+cast(dateadd(day,d2.days,d2.date_a) as char)
also the same result. (same result also when i convert into smalldatetime or datetime instead of char)what does this "NULL" in every row mean? SQL tells me that joining was succesfully but i cant see the values from table_2.thanks for help!