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 206381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:38:27+00:00 2026-05-11T17:38:27+00:00

Given these two queries: Select t1.id, t2.companyName from table1 t1 INNER JOIN table2 t2

  • 0

Given these two queries:

Select t1.id, t2.companyName 
from table1 t1 
  INNER JOIN table2 t2 on t2.id = t1.fkId 
WHERE t2.aField <> 'C' 

OR:

Select t1.id, t2.companyName 
from table1 t1 
  INNER JOIN table2 t2 on t2.id = t1.fkId  and t2.aField <> 'C'

Is there a demonstrable difference between the two? Seems to me that the clause “t2.aField <> ‘C'” will run on every row in t2 that meets the join criteria regardless. Am I incorrect?

Update: I did an “Include Actual Execution Plan” in SQL Server. The two queries were identical.

  • 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-11T17:38:27+00:00Added an answer on May 11, 2026 at 5:38 pm

    I prefer to use the Join criteria for explaining how the tables are joined together.
    So I would place the additional clause in the where section.

    I hope (although I have no stats), that SQL Server would be clever enough to find the optimal query plan regardless of the syntax you use.

    HOWEVER, if you have indexes which also have id, and aField in them, I would suggest placing them together in the inner join criteria.

    It would be interesting to see the query plan’s in these 2 (or 3) scenarios, and see what happens. Nice question.

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

Sidebar

Related Questions

Given two interface references obtained from different sources. Is there a programmatic way to
If I have two queries SELECT Id, Forename, Surname FROM Person WHERE PersonName Like(‘%frank%’)
What are the potential pros and cons of each of these queries given different
One of those classic programming interview questions... You are given two marbles, and told
Given that there are many sizes and color depths for different phones (even for
This is not a technical question, but given that there are a few iPhone
given a matrix of distances between points is there an algorithm for determining a
I’m having some difficulties with two queries. I can get some of the information
Given two tables, one for workers and one for tasks completed by workers, CREATE
I have a database for a Train company. I want to combine two queries

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.