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
 Two values of one table and joins using other tale

Author  Topic 

Jemy
Starting Member

3 Posts

Posted - 2012-05-20 : 11:33:14
Dear All,
I have a table of 'items' containing user codes who created and updated items. i need to pick the names in place of user codes from another table called users.
Please help me in doing the same.
Thanks


visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-05-20 : 12:00:05
just a simple inner join with user table on usercodes will do the trick for you

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Jemy
Starting Member

3 Posts

Posted - 2012-05-21 : 01:54:19
Dear Vishak,
Sorry for disturbing you again.
I have the following tables.
Table1 – oitm
Itemcode itemname usersign usersign2
Da8503 hose 1 12
Table2 – ousr
Userid u_name
1 manager
2 rajesh
I need to pick the table1 information with user names in place of user id
While inner join the following error message is getting.
‘The objects "oitm" and "oitm" in the FROM clause have the same exposed names. Use correlation names to distinguish them.’
Hope you got it.

Thanks
quote:
Originally posted by visakh16

just a simple inner join with user table on usercodes will do the trick for you

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/



Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-05-21 : 16:05:15
[code]
SELECT o.Itemcode,
o.itemname,
u1.u_name AS usersign,
u2.u_name AS usersign2
FROM oitm o
INNER JOIN ousr u1
ON u1.Userid = o.usersign
INNER JOIN ousr u2
ON u2.Userid = o.usersign2
[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Jemy
Starting Member

3 Posts

Posted - 2012-05-22 : 11:00:45
Yes it is working.
Thank you vishak. Thank you very much
Jemy


quote:
Originally posted by visakh16


SELECT o.Itemcode,
o.itemname,
u1.u_name AS usersign,
u2.u_name AS usersign2
FROM oitm o
INNER JOIN ousr u1
ON u1.Userid = o.usersign
INNER JOIN ousr u2
ON u2.Userid = o.usersign2


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/



Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-05-23 : 15:47:10
wc

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -