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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:23:14+00:00 2026-05-26T05:23:14+00:00

These are the (example) tables: first: id abc parent: id childid foo 1 0

  • 0

These are the (example) tables:

first:  id      abc

parent: id  childid  foo
         1        0       -- no  child
         2        1       -- one child

child:  id  abc  bar
         1
         2

last:   id  foo  bar

I would like to execute the following query:

SELECT
  first.*
 ,parent.*
 ,child.*
 ,last.*

FROM        first  -- actually some joins

-- select exactly 1 `parent` row for each `first` row
-- with an optional `child` row (or NULLs if child.id=0)
LEFT JOIN ( parent
LEFT JOIN   child ON child.id = parent.childid
                 AND child.abc = first.abc <== ERROR HERE
          )       ON parent.childid = 0
                  OR child.id


-- conditions referring to the parent,child rows
LEFT JOIN   last  ON last.foo = parent.foo
                 AND last.bar = child.bar

Unfortunately MySQL doesn’t like external references in the nested join:
Unknown column 'first.abc' in 'on clause'

I would be happy if someone could help me on fixing this type of query.

  • 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-26T05:23:15+00:00Added an answer on May 26, 2026 at 5:23 am
    1. Lose those brackets!
    2. ON parent.childid = 0 OR child.id is invalid. Use ON parent.childid in (0, child.id)

    It should look like this:

    ...
    LEFT JOIN  parent  -- removed opening bracket
    LEFT JOIN   child ON child.id = parent.childid
                     AND child.abc = first.abc 
                     AND parent.childid = in (0, child.Id) -- removed closing bracket and used 'IN'
    ...   
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Take these two example tables: Table A Name FirstOrLast Jeremy First Smith Last Mark
So I have these tables: STUDENTS: Student ID - First name - Last name
Web-Applications these days make extensive use of Javascript, for example various Google Products like
Consider these two tables stored in a MySQL database. The first stores a list
I have 2 tables. for this example I will use only one users records.
For simplicity I am going to use Northwind as an example... I would like
Is there a way to restrict certain tables from the mysqldump command? For example,
I am using these rules and conditions in .htaccess to turn these http://www.example.com/index.php/about/history http://www.example.com/about/history/index.php
For example, these are valid math expressions: a * b + c -a *
Can anyone provide a clear explanation / example of what these functions do, and

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.