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
 INSERT SELECTS

Author  Topic 

TheBoyDickie
Starting Member

2 Posts

Posted - 2011-09-20 : 09:24:18
Is there a way to select data from 2 tables i.e.

-Table1--------------Table2
Table1_id-----------Table2_id

Insert both ID's into the below table..

Table3
Table1_id
Table2_id

Any help would be much appreciated.

Thanks.

ehorn
Master Smack Fu Yak Hacker

1632 Posts

Posted - 2011-09-20 : 09:31:40
Hello,

Can you elaborate on what is the relationship between table1 and table2 id's?

Possible something like;

INSERT Table3 (id)

SELECT d.id
FROM
(
SELECT t1.id
FROM table1 t1

UNION <ALL>

SELECT t2.id
FROM table2 t2
) d

Go to Top of Page

TheBoyDickie
Starting Member

2 Posts

Posted - 2011-09-20 : 09:58:14
Table3 will be the relationship between the 2 tables.

Basically, Table1 is a users table and Table2 is a postcode table.

Hope that makes a little bit more sense.

Go to Top of Page
   

- Advertisement -