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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:24:55+00:00 2026-05-29T09:24:55+00:00

Working sample using one Table SELECT t.* FROM ( SELECT TITLE.name, (TITLE.value-TITLE.msp) AS Lower,

  • 0

Working sample using one Table

SELECT t.* FROM (
  SELECT
    TITLE.name, 
    (TITLE.value-TITLE.msp) AS Lower, 
    (TITLE.value+TITLE.msp) AS Upper,
    (TITLE.value) AS Value
  FROM TITLE 
) t
WHERE 98 BETWEEN t.Lower AND t.Upper
ORDER BY ABS(98 - t.Value) ASC
LIMIT 5

Desired example working with 3 tables (Needs fixed/help)

SELECT t.* FROM (
  SELECT
    TITLE.name, ALBUM.year, GENRE.Type
    (TITLE.value-TITLE.msp) AS Lower, 
    (TITLE.value+TITLE.msp) AS Upper,
    (TITLE.value) AS Value
  FROM TITLE, ALBUM, GENRE 
) t
WHERE ALBUM.ID=GENRE.ID AND TITLE.ID=ALBUM.ID  
AND 98 BETWEEN t.Lower AND t.Upper
ORDER BY ABS(98 - t.Value) ASC;

I get the following error:

ERROR 1054 (42S22): Unknown column ‘ALBUM.ID’ in ‘where clause’

  • 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-29T09:24:56+00:00Added an answer on May 29, 2026 at 9:24 am

    This is logical: your subquery creates one table t, and afterwords you try to refer to a table ALBUM. There is no ALBUM, there is only t

    The quickest fix it to move the WHERE clause for the JOIN where it belongs: in the subquery.

    SELECT t.* FROM (
      SELECT
        TITLE.name, ALBUM.year, GENRE.Type
        (TITLE.value-TITLE.msp) AS Lower, 
        (TITLE.value+TITLE.msp) AS Upper,
        (TITLE.value) AS Value
      FROM TITLE, ALBUM, GENRE 
      WHERE ALBUM.ID=GENRE.ID AND TITLE.ID=ALBUM.ID  
    ) t
    WHERE 98 BETWEEN t.Lower AND t.Upper
    ORDER BY ABS(98 - t.Value) ASC;
    

    The query itself ain’t that beautiful though… why not try this instead:

      SELECT
        TITLE.name, ALBUM.year, GENRE.Type
        (TITLE.value-TITLE.msp) AS Lower, 
        (TITLE.value+TITLE.msp) AS Upper,
        (TITLE.value) AS Value
      FROM TITLE
       JOIN ALBUM
        ON TITLE.ID=ALBUM.ID  
       JOIN GENRE 
        ON ALBUM.ID=GENRE.ID 
      WHERE 98 BETWEEN Lower AND Upper
      ORDER BY ABS(98 - Value) ASC;
    
    • Removed the unnecessary subquery
    • Used SQL-92 style JOIN instead of SQL-89 style JOIN (cartesian product with a where clause)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working a sample application using Windows Azure table storage. I will try
We are creating sample application for windows mobile using Rijndael algorithm. Its working fine.
So, working on a simple website (XHTML and CSS) formatted using a table, I
Whats this?? my query is: Doctrine_Query::create() ->select('rec.*') ->from('Records rec') ->execute(); Records table contains more
i am working on one application in which i have created one table view
Whenever I try to copy an entire working copy using simple drag and drop
I am working on a simple chat application using a System.Windows.Forms.WebBrowser Control to display
I am working on a simple budget app using Sinatra and DataMapper in Ruby.
I was working on a simple GUI script yesterday using jdbc in eclipse. When
I am currently working on a simple web application through Google App engine using

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.