Re: Problem with a join due to multiple Nulls
- From: "David Portas" <REMOVE_BEFORE_REPLYING_dportas@xxxxxxx>
- Date: 29 Mar 2006 01:45:58 -0800
chudson...@xxxxxxxxxxx wrote:
I want to join 2 tables by a unique ID field, but the ID field also has
multiple NULLS which I do not want to ignore and I fear they will cause
duplication.
Using TableA and TableB below i will demonstrate the problem.
TableA
TableA.ID Field1 Field2
1 Paul 1
Null John 1
2 John 1
TableB
TableB.ID Field3 Field4
1 25 1
Null 32 1
Null 23 1
2 26 1
The Table I want is
TableA.ID TableB.ID Field1 Field2 Field3 Field4
1 1 Paul 1 25 1
2 2 John 1 26 1
Null Null John 1 Null Null
Null Null Null Null 32 1
Null Null Null Null 26 1
I think a select distcinct statement with a full outer join may do what
I want, but I'm not certain so want to check.
Regards,
Ciarán
It appears that TableA doesn't have a key. Not clear what the key is in
TableB either. Please post DDL rather than sketches of tables otherwise
we just have to guess.
Based on what you've posted I'd say you need to fix some data model
issues (missing keys) before you attempt your query. Maybe that's what
you are trying to do but it isn't obvious how your requested output
will help you.
--
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--
.
- Follow-Ups:
- Re: Problem with a join due to multiple Nulls
- From: chudson007
- Re: Problem with a join due to multiple Nulls
- References:
- Problem with a join due to multiple Nulls
- From: chudson007
- Problem with a join due to multiple Nulls
- Prev by Date: Problem with a join due to multiple Nulls
- Next by Date: Re: Problem with a join due to multiple Nulls
- Previous by thread: Problem with a join due to multiple Nulls
- Next by thread: Re: Problem with a join due to multiple Nulls
- Index(es):
Relevant Pages
|