SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Two values of one table and joins using other tale
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Jemy
Starting Member

United Arab Emirates
3 Posts

Posted - 05/20/2012 :  11:33:14  Show Profile  Reply with Quote
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

India
47099 Posts

Posted - 05/20/2012 :  12:00:05  Show Profile  Reply with Quote
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

United Arab Emirates
3 Posts

Posted - 05/21/2012 :  01:54:19  Show Profile  Reply with Quote
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

India
47099 Posts

Posted - 05/21/2012 :  16:05:15  Show Profile  Reply with Quote

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

Jemy
Starting Member

United Arab Emirates
3 Posts

Posted - 05/22/2012 :  11:00:45  Show Profile  Reply with Quote
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

India
47099 Posts

Posted - 05/23/2012 :  15:47:10  Show Profile  Reply with Quote
wc

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

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000