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
 Joining two tables

Author  Topic 

johnnykenshien
Starting Member

2 Posts

Posted - 2008-06-15 : 21:45:08
Hello friends,

Im a begginer in SQL Server and I just to ask for help on how to this this tables



table1

Field1
123
1234
12
154
123
321
123
21

Table2

Field1
test1
test2
test3
test4
test5
test6

desired output

Field1 Field1
123 test1
1234 test2
12 test3
154 test4
123 test5
321 test6
123
21

can i ask for script how to join this table? i try this script but it doest work.

select table1.col1,table2.col1
from table1
left join table2
ON table1.col1 is NOT NULL

Thanks in advance and more power!

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-16 : 00:12:17
Dont you have a column by which the two tables are related? If that column is col2 you can write:-

SELECT t1.field1,t2.field1
FROM Table1 t1
LEFT JOIN Table2 t2
ON t1.col2=t2.col2
Go to Top of Page

shobinmathew
Starting Member

16 Posts

Posted - 2008-06-16 : 07:17:36
is ther any primary key - foreign key relation ship
Go to Top of Page
   

- Advertisement -