-
T-SQL ****
Hi
This is most likely an easy question but here it goes...
I have two tables tblUser and tblType These are as follows:
tblUser:
uID (User identifier.. Unique)
uName (Name of user)
uType (Type of user.. This value is a reference to a tID in tblType)
tblType:
tID (Type Identifier... Unique)
tTitle (Type title.. This could be ASP Programmer)
Now the question... I have a user created in tblUser .. This user is an ASP
Programmer... This would mean that tblUser.uType = tblType.tID.. How can I
do a T-SQL query (ex. "SELECT uName FROM tblUser") so that I don't get a
value in tblUser.uType but instead the text from the related field in
tblType??
Thanks in advance
Best regards
Kim Pedersen
-
Re: T-SQL ****
Kim
You can use an inner join to accomplish this. Something like;
select tblUser.uName, tblType.tTitle
from tblUser
inner join tblType
on tblUser.uType = tblType.tID
where tblUser.uID = ***
You could also use an implied inner join with the 'where' statement.
Hope that helps.
"Kim Pedersen [vbCode Magician]" <codemagician@nospam.get2net.dk> wrote in
message news:3a11d04a@news.devx.com...
> Hi
>
> This is most likely an easy question but here it goes...
>
> I have two tables tblUser and tblType These are as follows:
>
> tblUser:
> uID (User identifier.. Unique)
> uName (Name of user)
> uType (Type of user.. This value is a reference to a tID in tblType)
>
> tblType:
> tID (Type Identifier... Unique)
> tTitle (Type title.. This could be ASP Programmer)
>
> Now the question... I have a user created in tblUser .. This user is an
ASP
> Programmer... This would mean that tblUser.uType = tblType.tID.. How can I
> do a T-SQL query (ex. "SELECT uName FROM tblUser") so that I don't get a
> value in tblUser.uType but instead the text from the related field in
> tblType??
>
> Thanks in advance
>
> Best regards
> Kim Pedersen
>
>
-
Re: T-SQL ****
Hi Craig
> You can use an inner join to accomplish this. Something like;
>
> select tblUser.uName, tblType.tTitle
> from tblUser
> inner join tblType
> on tblUser.uType = tblType.tID
> where tblUser.uID = ***
>
> You could also use an implied inner join with the 'where' statement.
>
> Hope that helps.
That works just fine.. Thanks for helping me out..
Hilsen/Best regards
Kim Pedersen
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks