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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:15:20+00:00 2026-06-01T05:15:20+00:00

I ran into a little error trying to select off of my table. I

  • 0

I ran into a little error trying to select off of my table. I am sure it is an easy fix but I can’t seem to locate the problem. It seems that my error message is telling me that I am selecting off a column that does not exist, even though it does.

The code

SELECT TOP (20) id 
FROM school b 
WHERE b.state = school.state 
AND b.id <> school.id 
ORDER BY NEWID()

The table “school”

School table

The error msg

Error msg

  • 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-01T05:15:22+00:00Added an answer on June 1, 2026 at 5:15 am

    What are you trying to achieve with this query?

    In the WHERE clause you appear to think you are querying from two tables:

    WHERE b.state = school.state
    

    but your FROM clause only specifies a single table:

    FROM school b 
    

    The error messages is telling you that school.state is an invalid identifier. This is in fact true, because you have aliased the SCHOOL table, so only b.state is valid in the scope of the statement.

    I think you trying to identify the IDs of schools which are in the same state as other schools. In which case you need to join it to itself, something like this:

    SELECT TOP (20) b.id 
    FROM school a join school b 
       on  b.state = a.state 
          and  b.id <> a.id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ran into this error message while trying to select some records off a table.
I ran into a little problem today that I can't seem to solve in
I just ran into a little error in my MVC application. Administrators can edit
I ran into this error, and found very little documentation on how to fix
I was trying to do a little data access optimization, and I ran into
Ran into an Out of Stack Space error trying to serialize an ASP.Net AJAX
Ran into a little problem and I'm not entirely sure why this code won't
I recently ran into a little trouble with sending SMSes as sendTextMessage can only
I ran into something a little odd this morning and thought I'd submit it
I've recently ran into a little for when an object fails to save due

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.