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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 JOIN TABLE

Author  Topic 

u2p_inst
Yak Posting Veteran

78 Posts

Posted - 2002-07-23 : 23:13:50
DEAR ALL

can i join 2 tables without have a foreign key??

oh

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-07-23 : 23:23:34
Yes.

Go to Top of Page

u2p_inst
Yak Posting Veteran

78 Posts

Posted - 2002-07-25 : 01:58:20
how?

oh
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-07-25 : 07:31:45
Use the JOIN operator. It's documented in SQL Server Books Online.

You can also look here:

http://www.sqlteam.com/FilterTopics.asp?TopicID=137

Go to Top of Page

dataphile
Yak Posting Veteran

71 Posts

Posted - 2002-07-25 : 11:13:42
select l.field1, r.field1
from lefttable l inner join righttable r on l.field1 = r.field1

Same as if you had a foreign key on field1.

However your referential integrity might be a @#$%@#$%
so you might have to play around with "left outer join"
"right outer join" and "full outer join"
until you understand you clean or dirty the data is.
Go to Top of Page

u2p_inst
Yak Posting Veteran

78 Posts

Posted - 2002-07-26 : 02:57:43
thanks all

oh
Go to Top of Page
   

- Advertisement -