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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:45:31+00:00 2026-05-11T12:45:31+00:00

After 5.0.12 MySQL changed the syntax for left joins to match SQL2003 standard. So

  • 0

After 5.0.12 MySQL changed the syntax for left joins to match SQL2003 standard. So

... FROM t1 , t2 LEFT JOIN t3 ON (expr) 

needs to be rewritten as

... FROM (t1 , t2) LEFT JOIN t3 ON (expr 

or else it will be parsed as ... FROM t1 , (t2 LEFT JOIN t3 ON (expr))

Now, I have an ancient app I’m porting from MySQL 3.23 (eek!) to 5.1, and the old code has this query:

select b.*, c.*, g.*, p.perfname, p.persname  from bookings b, customer c  left join grade g on b.chrggrade=g.grcode  left join person p on b.person=p.percode  where complete='Y' and invoiced='N'  and datemade between '2009-03-25' and '2009-03-31'  and c.custcode=b.cust  order by cust, person, tsref, stdt  

This fails with SQL error 1054, unknown column in b.chrggrade. This is because it’s parsing as

select b., c., g.*, p.perfname, p.persname from bookings b, (customer c left join grade g on b.chrggrade=g.grcode ) left join person p on b.person=p.percode where complete=’Y’ and invoiced=’N’ and datemade between ‘2009-03-25’ and ‘2009-03-31’ and c.custcode=b.cust order by cust, person, tsref, stdt

I think.

I’m sure correctly placed brackets can fix this but I’m stumped. I found reference to this change at http://bugs.mysql.com/bug.php?id=13551, which shows how to fix a simple left join, but I still can’t work it out for this query. David

  • 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. 2026-05-11T12:45:32+00:00Added an answer on May 11, 2026 at 12:45 pm

    Stop using the comma syntax altogether and be explicit in your JOIN statements. The comma syntax forces you to put the JOIN condition in the WHERE clause, which may not get executed until after LEFT/RIGHT joins, depending on how it’s parsed. Using explicit JOINS makes the query more readable anyway.

    …FROM t1, t2 LEFT JOIN t3 ON (expr) becomes …FROM t1 INNER JOIN t2 ON (expr) LEFT JOIN t3 ON (expr)

    That will also fix the error you are seeing. Unless there is no chrggrade in the bookings table, then nothing will fix the error.

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

Sidebar

Related Questions

I'm changing my mysql db table from an id (auto) to a uid. ALTER
Scenario: I load some data into a local MySQL database each day, about 2
How can I change the MySQL query delimiter using the C API? I tried
I'm trying to set up a MySQL trigger, but I can't figure out how
mysql> ALTER TABLE bdds_arts ADD test VARBINARY; ERROR 1064 (42000): You have an error
I have a table: CREATE TABLE `data_table` ( `data_id` INT NOT NULL AUTO_INCREMENT PRIMARY
Okay, so I have this CSV file of products and all the products have
I've used following code to generate database creation script Configuration configuration = new Configuration();
I would like to rename an index. I've looked at the alter table documentation,

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.