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
 General SQL Server Forums
 New to SQL Server Programming
 join two columns from different tables to a table

Author  Topic 

goligol
Posting Yak Master

128 Posts

Posted - 2012-07-19 : 11:39:13
Hello,

I am trying to join two columns of two tables to an existing table. all tables have the same size: Do you have any comment to do so


SELECT [ifmb]
,[imiters_io]
,[cfmb]
,[cmiters_io]
,[fov]
FROM [BLS].[dev].[A1993_nrg_cxcuse]a

join
select [fov] fov1
FROM [BLS].[dev].[A1994_nrg_cxcuse] b
where a.[ifmb] = b.[ifmb]
and a.[imiters_io] = b.[imiters_io]
and a.[cfmb] = b. [cfmb]
and a.[cmiters_io] = b.[cmiters_io]

join
select [fov] fov2
FROM [BLS].[dev].[A1995_nrg_cxcuse] c
where a.[ifmb] = c.[ifmb]
and a.[imiters_io] = c.[imiters_io]
and a.[cfmb] = c. [cfmb]
and a.[cmiters_io] = c.[cmiters_io]

thank you

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2012-07-19 : 11:41:22
http://www.sqlservercentral.com/articles/Best+Practices/61537/
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-07-19 : 13:12:46
syntax itself is wrong. see here to start on join basics

http://www.mssqltips.com/sqlservertip/1667/sql-server-join-example/

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -