Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1030249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:40:13+00:00 2026-05-16T12:40:13+00:00

(this question is very similar to my previous question Does it matter where I

  • 0

(this question is very similar to my previous question Does it matter where I check part of a composite key when joining two tables in SQL Server?)

I’m joining three tables on a composite key, with the value of one of the columns being determined by user input. I’m wondering if it matters where I compare the corresponding columns when I do the joins.

Say I have a table, TableA, with columns ColAFoo, ColAFoo2, and ColABar. TableA has a composite primary key comprising ColAFoo and ColAFoo2 (PK_TableA).

I also have TableB, with ColBFoo, ColBFoo2, and ColBOther. TableB’s columns ColBFoo and ColBFoo2 comprise a foreign key to TableA’s primary key (FK_TableA_TableB).

Finally, I have TableC, with ColCFoo, ColCFoo2, ColCBlah, and ColCBlah2. TableC’s columns ColCFoo and ColCFoo2 comprise a foreign key to TableA’s primary key (FK_TableA_TableC). I’ll also say that TableC has a composite primary key comprising ColCFoo, ColCFoo2, and ColCBlah.

I need to join the three tables on the key. Is there a difference between the following (contrived) statements in terms of performance?

SELECT *
  FROM TableA a
  JOIN TableB b
    ON  a.ColAFoo = b.ColBFoo
        AND a.ColAFoo2 = b.ColBFoo2
  JOIN TableC c
    ON  a.ColAFoo = c.ColCFoo
        AND a.ColAFoo2 = c.ColCFoo2
  WHERE a.ColAFoo2 = @userInput

SELECT *
  FROM TableA a
  JOIN TableB b
    ON  a.ColAFoo = b.ColBFoo
        AND a.ColAFoo2 = b.ColBFoo2
  JOIN TableC c
    ON  a.ColAFoo = c.ColCFoo
  WHERE a.ColAFoo2 = @userInput
        AND c.ColCFoo2 = @userInput

SELECT *
  FROM TableA a
  JOIN TableB b
    ON  a.ColAFoo = b.ColBFoo
  JOIN TableC c
    ON  a.ColAFoo = c.ColCFoo
  WHERE a.ColAFoo2 = @userInput
        AND b.ColBFoo2 = @userInput
        AND c.ColCFoo2 = @userInput
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T12:40:14+00:00Added an answer on May 16, 2026 at 12:40 pm

    No. The query optimiser will recognise if these are all the same.

    Best thing to do with this sort of question is just to look at the estimated execution plans and see if there are any differences.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question is very similar to SQL Server 2005: T-SQL to temporarily disable a
Very similar to this question , except for Java. What is the recommended way
Liu Chang asked a very similar question to this one here, Linux equivalent of
My question is very similar to this question. I want to be able to
In a similar vein to my previous question - I'm not a very experienced
I found this question , which is very similar to what I want but
In similar vein to this previous question , I a looking to implement user
This question was very helpful, however I have a list control in my report,
I apologise in advance if this question isn't very specific. Would it be possible
I will begin this question by admitting I am very new to MVC. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.