SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2010
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    INNER JOIN for multiple tables ??

    Hi all

    I just want to ask if I got my T-SQL right? I write a statement to get all task and project for login user

    Code:
    SELECT Users.userName, Tasks.taskName, Tasks.priority AS TaskPriority, Tasks.createdOn AS TaskcreatedOn, Tasks.estTime, Projects.projectName, Tasks.taskID, Users.userID, Projects.projectID 
    FROM Users INNER JOIN Users_projects AS usp ON usp.userID = Users.userID 
    INNER JOIN Projects ON usp.projectID = Projects.projectID 
    INNER JOIN Projects_tasks ON Projects.projectID = Projects_tasks.projectID 
    INNER JOIN Tasks ON Projects_tasks.taskID = Tasks.taskID

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,262
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by a-elnajjar View Post
    I just want to ask if I got my T-SQL right?
    what happened when you tested it?

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Enthusiast
    Join Date
    Oct 2010
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it run without any problem but just I want to make sure I get right and to see if their are more way to optimize it ?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •