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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:48:07+00:00 2026-06-10T22:48:07+00:00

I facing with a strange situation with a sql query on mysql 5.1.41 environment

  • 0

I facing with a strange situation with a sql query on mysql 5.1.41 environment on a Ubuntu machine.

The code follow

SELECT spedizione0_.idspedizione,
    spedizione0_.*,
    (
        SELECT COUNT(n.idnegozio)
        FROM negozio n
        LEFT JOIN confezione c
            ON n.idnegozio = c.idnegozio
                AND c.idspedizione = spedizione0_.idspedizione
        WHERE n.datainizio <= spedizione0_.dataspedizione
            AND n.datafine >= spedizione0_.dataspedizione
            OR c.idspedizione != 0
        ) AS formula5_
FROM orocashgenerico.spedizione spedizione0_
ORDER BY spedizione0_.dataspedizione DESC

In this case the error says : [Err] 1054 – Unknown column ‘spedizione0_.idspedizione’ in ‘on clause’

The only way to run this query is to change the .. on n.idnegozio=c.idnegozio and c.idspedizione=spedizione0_.idspedizione into on n.idnegozio=c.idnegozio and c.idspedizione=12

The most strange things for me is: if i move the and condition to the where clause the query run correctly, of course the results is not what I excepted.

My question is where is the problem?
Is something related to the MySQL version?

  • 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-10T22:48:08+00:00Added an answer on June 10, 2026 at 10:48 pm

    It’s because spedizione0_ is not found with the scope of your subquery. Try this one,

    SELECT  spedizione0_.idspedizione,                     // add additionl columns
            COUNT(n.idnegozio) AS formula5_                
    FROM    spedizione spedizione0_
            LEFT JOIN confezione c
                ON c.idspedizion = spedizione0_.idspedizione
            LEFT JOIN negozio n
                ON n.idnegozio = c.idnegozio
    WHERE   (
                n.datainizio <= spedizione0_.dataspedizione AND 
                n.datafine >= spedizione0_.dataspedizione
            )
                OR c.idspedizione != 0
    GROUP By spedizione0_.idspedizione
    ORDER BY spedizione0_.dataspedizione DESC
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am facing a strange problem on my Ubuntu Karmic system. When I call
I am new to VB.net and facing a strange situation. I have a structure
I'm facing the same issue, while trying for cross-domain request. Situation is strange, my
I am facing strange issue with our WCF service. The same code was working
Im facing a strange issue trying to move from sql server to oracle. in
I'm facing a strange issue with some TSQL code on SQL2005. The piece we
I'm facing a strange issue in R. Consider the following code (a really simplified
since today im facing a strange problem. When i start my app in my
I am facing a strange issue.It is working well with outlook 2K3 but not
I am facing a strange problem and have no idea how to fix this

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.