Monday, March 19, 2012

Joining on more than 1 field ?

Hi,
Is it possilbe to join 2 tables on more than one field ?
Like
SELECT *
FROM tblONE A JOIN tblTWO B ON
(a.one = b.one AND a.two = b.two AND a.three = c.three);
I tried this and would not run.
ANy suggestions ?What was the error?

Are table names case sensitive in SQL Server? If so, you may need to edit your alias'.

Matt. :)|||Originally posted by Mincer
What was the error?

Are table names case sensitive in SQL Server? If so, you may need to edit your alias'.

Matt. :)

Oh

thanks..
must've just mistyped...
tired =)

thanks again..

u have any suggestions for my other post 'finding distinct combinations'

http://dbforums.com/t916080.html|||SELECT *
FROM tblONE A JOIN tblTWO B ON
(a.one = b.one AND a.two = b.two AND a.three = c.three);

You're referencing an alias 'c' ... 'a.three = c.three' that you haven't created. Should it be 'b' instead? I don't think case is an issue with an Alias, and I don't think you need the parens either.

No comments:

Post a Comment