T-SQL ****


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: T-SQL ****

  1. #1
    Kim Pedersen [vbCode Magician] Guest

    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



  2. #2
    Craig Guest

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




  3. #3
    Kim Pedersen [vbCode Magician] Guest

    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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center