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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:13:09+00:00 2026-05-12T08:13:09+00:00

When joining to a subset of a table, any reason to prefer one of

  • 0

When joining to a subset of a table, any reason to prefer one of these formats over the other?

Subquery version:

SELECT ...
FROM Customers AS c
INNER JOIN (SELECT * FROM Classification WHERE CustomerType = 'Standard') AS cf
    ON c.TypeCode = cf.Code
INNER JOIN SalesReps s ON cf.SalesRepID = s.SalesRepID

vs the WHERE clause at the end:

SELECT ...
FROM Customers AS c
INNER JOIN Classification AS cf ON c.TypeCode = cf.Code
INNER JOIN SalesReps AS s ON cf.SalesRepID = s.SalesRepID
WHERE cf.CustomerType = 'Standard'

The WHERE clause at the end feels more “traditional”, but the first is arguably more clear, especially as the joins get increasingly complex.

Only other reason I can think of to prefer the second is that the “SELECT *” on the first might be returning columns that aren’t used later (In this case, I’d probably only need to return cf.Code and Cf.SalesRepID)

  • 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-12T08:13:10+00:00Added an answer on May 12, 2026 at 8:13 am

    What about a third option?

    SELECT ...
    FROM Customers AS c
    INNER JOIN Classification AS cf 
        ON cf.CustomerType = 'Standard' 
        AND c.TypeCode = cf.Code
    INNER JOIN SalesReps AS s 
        ON cf.SalesRepID = s.SalesRepID
    

    Personally, I prefer to use JOIN syntax to indicate the statements on which the overall set is defined, the foreign keys or other conditions that indicate two rows should be joined to make a row in the result set.

    The WHERE clause contains the criteria which filter my result set. Arguably, this can become quite bloaty and complicated when you are performing a number of joins, however when you think in sets it follows a kind of logic:

    • SELECT what columns I want.
    • JOIN tables to define the set I want to get rows from.
    • Filter out rows WHERE my criteria are not met.

    By this logic, I’d always choose your second syntax for consistent readability.

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

Sidebar

Related Questions

I have table a joining table b, I only want the records from table
i'm joining tables like: select * from tableA a full join tableB b on
I have a normal joining table with two columns that are keys to other
I am joining 2 tables using Cartesian Product as follows. select p.type, i.amount FROM
i am joining 2 tables using this query SELECT DISTINCT (member.id), member_type FROM member
I have 3 tables and I am joining these 2 tables as follows: SELECT
I'm JOINing the results of this query: SELECT twitter_personas.id , 'TwitterPersona' , twitter_personas.name FROM
I am joining my address book onto my email table like this: SELECT *
Update a table joining 1 more table. UPDATE t1 SET t1.col1 =1 FROM table1
I am LEFT JOINing multiple tables as such: SELECT * FROM table1 LEFT JOIN

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.