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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 - pb using inner join

Author  Topic 

rtutus
Aged Yak Warrior

522 Posts

Posted - 2006-07-16 : 17:57:37
- using Inner join when the field in my data table has the Null default value:
I have a datatable : Data_Table and a look up table: Lk_table. Myfield that I use in Inner Join is defined in both the data and look table.

So I build my query like this:
SELECT * FROM dbo. Data_Table INNER JOIN
dbo. Lk_table ON dbo.Data_Table.MyField = dbo.Lk_table.Myfield

The pb, sometimes I have myfield still with its default null value in the datatable: Data_Table. So, I end up getting 0 record when I execute the query shown above.
How do I turn that around so that even if myfield in Data_Table is Null, I still get the records from Data_Table. (I don t want a set of records including all possible values from the look up table: Lk_Table)

Thanks

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-07-16 : 18:05:09
[code]SELECT *
FROM dbo.Data_Table
LEFT JOIN dbo.Lk_table ON dbo.Data_Table.MyField = dbo.Lk_table.Myfield[/code]
Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -