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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:55:48+00:00 2026-05-31T21:55:48+00:00

Strange situation. If I have these tables: CREATE TABLE t1 (id INT, title VARCHAR(20),

  • 0

Strange situation.

If I have these tables:

CREATE TABLE t1 (id INT, title VARCHAR(20), someIntCol INT)
GO
CREATE TABLE t2 (id INT, t1Id INT, someData VARCHAR(20))
GO

and do:

SELECT    t1.* 
FROM    t1 
WHERE    t1.id IN (SELECT someIntCol FROM t2)

weird thing: the parser doesn’t mind that the column someIntCol doesn’t exist

weirdest thing: if I change someIntCol to someIntCol2, I get a “Invalid column name ‘someIntCol2’.” error

Can anyone explain that?

FYI, this is not my code. I got it from this link

  • 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-31T21:55:49+00:00Added an answer on May 31, 2026 at 9:55 pm

    Try:

    SELECT    t1.* 
    FROM    t1 
    WHERE    t1.id IN (SELECT t2.someIntCol FROM t2)
    

    This will now throw an exception when executed.

    Because someIntCol exists in t1, it is using that data item from the main query.

    Sub-queries are able to use data items from the main query. Therefore to avoid this, specify the table name when entering your data item:

    SELECT [TableName].[ColumnName]
    

    This will also prevent ambiguity if you have 2 columns with the same name in t1 and t2


    Heres an MSDN which may give you a better understanding of how subqueries work:

    http://msdn.microsoft.com/en-us/library/aa213262(v=sql.80).aspx

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

Sidebar

Related Questions

Sorry for the strange title. Here is my situation. I have a table of
I guess this is strange situation. I have a results table which contain 100k
I have a very strange situation. I have a large set of records to
I have a very strange situation. I´m working on a pretty big Java application
I have a strange situation in regards to xml serialization... If I run MyApp.exe
I have a strange situation here. In my android app, I have a layout
I have the next very strange situation and problem: .NET 4.0 application for diagram
i have a SEAM 2 application and i have a strange situation. I'm developing
Strange situation - examples from apple works, but after i change them a bit,
Strange situation: I am trying to remove some hard coding from my code. There

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.