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)
 Two Tables from two different databases

Author  Topic 

tradingpassion
Starting Member

24 Posts

Posted - 2005-05-26 : 00:13:34

I have two databases
ABC
XYZ

I have user_id field on one of them(ABC database) with the table let's say abc_customer

I want to get the users names instead of their IDS so I go to the other database(XYZ) and it has a table called XYZ_customer and has two fields USER_ID and USER_NAME

I want to join these two so that I can get the name instead of ID on the first database...and here is what I am doing



SELECT USER_NAME
FROM abc..abc_Customer AS SU
INNER JOIN xyz_customer as C
ON C.USER_ID = SU.user_id

I ma getting some answers but those are not right???I will appreciate if you can advice me what am I doing wrong

raclede
Posting Yak Master

180 Posts

Posted - 2005-05-26 : 00:38:25
SELECT xyz..xyz_customer.username
FROM xyz..xyz_customer
RIGHT JOIN abc..abc_customer
ON xyz..xyz_customer.userid = abc..abc_customer.userid


raclede
Go to Top of Page

raclede
Posting Yak Master

180 Posts

Posted - 2005-05-26 : 00:41:31
quote:
Originally posted by tradingpassion


I have two databases
ABC --- assumingly 1st database
XYZ --- assumingly 2st database

I want to get the users names instead of their IDS so I go to the other database(XYZ) and it has a table called XYZ_customer and has two fields USER_ID and USER_NAME

I want to join these two so that I can get the name instead of ID on the first database...and here is what I am doing



SELECT USER_NAME
FROM abc..abc_Customer AS SU
INNER JOIN xyz_customer as C
ON C.USER_ID = SU.user_id

I ma getting some answers but those are not right???I will appreciate if you can advice me what am I doing wrong





very confusing..

raclede
Go to Top of Page
   

- Advertisement -