SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Vlookup and Sum
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

jfm
Posting Yak Master

134 Posts

Posted - 07/17/2012 :  06:20:28  Show Profile  Reply with Quote
Hi there,

I have Table_1 and Table_2.

Table_1 has just Column_A, Table_2 has Column_A and many other columns.

I need to take the info from Table_1.Column_A and match with the same values of Table_2.ColumnA

Creating a New_Table using Table_2.Column_A (matched with Table_1.ColumnA values) and Column_P.

New Table= ColumnA, Column P

I'm trying yo use OUTER JOIN but is not working...

Any ideas? Thanks!

lionofdezert
Aged Yak Warrior

Pakistan
864 Posts

Posted - 07/17/2012 :  06:33:31  Show Profile  Visit lionofdezert's Homepage  Send lionofdezert a Yahoo! Message  Reply with Quote
unable to understand

Creating a New_Table using Table_2.Column_A (matched with Table_1.ColumnA values) and Column_P.

New Table= ColumnA, Column P


--------------------------
http://connectsql.blogspot.com/

Edited by - lionofdezert on 07/17/2012 06:34:23
Go to Top of Page

jfm
Posting Yak Master

134 Posts

Posted - 07/17/2012 :  06:50:46  Show Profile  Reply with Quote
Sorry for my explanation.

In Table_2, I have ID_Column and Postcode_Column.

In table_1, I only have ID_Column .

I need to match, the ID's that I have equal in both Tables, and create a New_Table that contains ID_Column and Postcode_Column (only the ones that matches with the ID_Column)

Thanks a lot


Go to Top of Page

webfred
Flowing Fount of Yak Knowledge

Germany
8529 Posts

Posted - 07/17/2012 :  06:53:04  Show Profile  Visit webfred's Homepage  Reply with Quote
use inner join


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

jfm
Posting Yak Master

134 Posts

Posted - 07/17/2012 :  07:53:55  Show Profile  Reply with Quote
I have a problem using INNER JOIN. Is working, but I can create the table.

Using:

Select * from Table_1
INNER JOIN Table_2
ON Table_1.ID = Table_2.ID

Its correct, but I don't have my table, in order to work with the data


So using:

Select Table_1.*
INTO Table_3
From Table_1
INNER JOIN Table_2
ON Table_1.Id = Table_2.ID

Table_3 just has the ID column, instead of having all the columns. And I need the data that I have using the first query.

Im sure im missing something in the process, but I don't know what.

Any idea?

Many thanks
Go to Top of Page

webfred
Flowing Fount of Yak Knowledge

Germany
8529 Posts

Posted - 07/17/2012 :  08:21:08  Show Profile  Visit webfred's Homepage  Reply with Quote
select
t1.Id,
t2.Column_P
into Table_3
from Table_1 as t1
inner join Table_2 as t2 on t1.Id = t2.Id



No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

jfm
Posting Yak Master

134 Posts

Posted - 07/17/2012 :  09:38:32  Show Profile  Reply with Quote
Thanks for your reply,

I can use the query is working, this way:

select
t1.Id, t2.Column_P
into Table_3
from Table_1
inner join Table_2
on t1.Id = t2.Id

Many thanks



Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000