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
 Basic Question

Author  Topic 

David Wadsworth
Starting Member

17 Posts

Posted - 2011-03-21 : 07:56:31
Hello,

I think I am having a grey moment and have forgotten (or never knew) how to do something basic.

Example table
UIN Name AssociateWith
1 AAA NULL
2 BBB NULL
3 CCC 1

I want to return all records so
SELECT UIN,Name,AssociateWith FROM yada

Returns
1 AAA NULL
2 BBB NULL
3 CCC 1

BUT I want the third lin,e third value (currently 1) to be 'AAA' which is the name not the UIN that is AssociateWith column.

I have looked back through all of the code I have written but cannot find out how to do this?

If you tell me, I promised to go "AAAAAAARRRRGGGHHHHH" and remember instantly.

Regards

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2011-03-21 : 08:02:11
SELECT y.UIN,y.Name,t.Name
FROM yada y
LEFT JOIN table t on y.AssociatedWith = t.UIN
Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

David Wadsworth
Starting Member

17 Posts

Posted - 2011-03-21 : 10:45:54
Dear jimf,

OMG (without Peaches Geldof) I did have a moment and I didnt get it until I read your reply.

I am gonna give up coding and do gardening.

Thanks mate.

David (blushing)
Go to Top of Page
   

- Advertisement -