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

  • SEARCH
  • Home
  • 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 9281979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T18:15:23+00:00 2026-06-18T18:15:23+00:00

As far as I know, at least in SQL Server, we can’t use an

  • 0

As far as I know, at least in SQL Server, we can’t use an alias from a table in a set that is being used to join with that table.

In an example:

CREATE TABLE A (A1 int, A2 int)
CREATE TABLE B (B1 int, B2 int)
SELECT a.A2
FROM
  A as a
INNER JOIN
  (SELECT * FROM B as b WHERE b.B1=a.A1) b2 ON b2.B2=a.A2

That query will result in an error because the alias a is being used in the set that would be joined to the table where the alias refer (A).

In SQL Server this could be solved using the CROSS APPLY, or maybe by re-writing the query. (This is NOT my question).

My question is: Why does this restriction exists?, why not let use the alias as the SQL Server CROSS APPLY?

My first guess is: Parallelism. If we can restrict this, each set that appear to be joined could always be computed in parallel and then joined. But it is just a guess. It could be more flexible and let me use the alias and compute dependencies between joining sets as I guess does CROSS APPLY.

Maybe there isn’t a why 🙂

  • 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-06-18T18:15:25+00:00Added an answer on June 18, 2026 at 6:15 pm

    The restriction exists because of the scoping rules for standard SQL. One table in a from clause just doesn’t know what is happening inside another table. Remember, SQL is a descriptive language not a procedural language. The order of the tables in the from clause is not at all necessarily related to the actual order they are processed in.

    This restriction does not apply in SELECT, WHERE, and HAVING clauses, because the FROM clause is evaluated first.

    As for the cross apply being the same or different from a join. There are many ways to write joins and the explicit join syntax is just one of them. Correlated subqueries, nested queries in selects, exists with subqueries, and in with subqueries are all performing some variant of the relational join operation. They are expressed differently.

    The uses of cross apply with a subquery are also, generally, types of joins. There may be some cases with very complex queries with nested uses of windows function where it may not be possible to rewrite the query as an explicit join. In most cases, though, I have been able to.

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

Sidebar

Related Questions

So far I know that FileSystemWatcher can look into a folder and if any
As far as I know that JSF keeps all the session scoped bean in
As far as I know, VisualSVN Server is a server while TortoiseSVN is a
as far as i know there are cross domain restictions that wont allow you
As far as I know de standard folder for Users (usually C:\Users) can be
Does anyone know of a definitive list of LINQ to SQL query limitations that
As far as know, I must be careful with PHP, and I think Javascript.
as far as I know both 2012-07-04T17:30:52+00:00 and 2012-07-04T17:30:52Z are dates in iso8601 format
As far as I know there is no way to migrate existing Facebook comments
As far as I know, C2DM is per app per device thing..but my question

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.