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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:07:12+00:00 2026-05-20T01:07:12+00:00

1st piece of background inf : This is about cms which holds object –

  • 0

1st piece of background inf : This is about cms which holds object – object relations and their sorting in single table, columns are object_id, parent_id and sorting order

2nd piece have query with several joins, which i want to sort by 2 parameters. One of those is sorting of the object itself and 2nd is the sorting order of its parent.

The query i have for now is:

SELECT obj_asset.*, object.headline AS title, oo.sort_order AS sort, op.sort_order FROM obj_asset 
JOIN object ON obj_asset.object_id = object.object_id 
JOIN object_object AS oo on obj_asset.object_id = oo.object_id
JOIN (SELECT sort_order from object_object WHERE object_id = (SELECT parent_id from object_object WHERE object_id = obj_asset.object_id )) AS op ON obj_asset.object_id = oo.object_id
WHERE obj_asset.profile_id = 140 AND obj_asset.rsvp_enabled = 1 AND object.is_published = 1 ORDER BY sort DESC;

And it does not work. This works fine though:

SELECT obj_asset.*, object.headline AS title, oo.sort_order AS sort, op.sort_order FROM obj_asset 
JOIN object ON obj_asset.object_id = object.object_id 
JOIN object_object AS oo on obj_asset.object_id = oo.object_id
JOIN (SELECT sort_order from object_object WHERE object_id = (SELECT parent_id from object_object WHERE object_id = 11111 )) AS op ON obj_asset.object_id = oo.object_id
WHERE obj_asset.profile_id = 140 AND obj_asset.rsvp_enabled = 1 AND object.is_published = 1 ORDER BY sort DESC;

The error i get is:

1054 – Unknown column ‘obj_asset.object_id’ in ‘where clause’

How can i get it working?

Thanks!

EDIT: i could get around the problem, if i could come up with alternate way to include parents sorting into the query. IS there such a way?

  • 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-20T01:07:12+00:00Added an answer on May 20, 2026 at 1:07 am

    As you already figured out, the problem is that you are trying to use a column from an outer query in a constraint of a subquery:

      (SELECT sort_order
          from object_object
          WHERE object_id = (SELECT parent_id
                             from object_object
                             WHERE object_id = obj_asset.object_id )
         )
    

    This subquery can be rewritten, but it is not clear how when only looking at your original query.

    There is probably an error in your original query (reformatted):

    SELECT obj_asset.*, object.headline AS title, oo.sort_order AS sort, op.sort_order
    FROM obj_asset 
    JOIN object ON obj_asset.object_id = object.object_id 
    JOIN object_object AS oo on obj_asset.object_id = oo.object_id
    JOIN (SELECT sort_order
          from object_object
          WHERE object_id = (SELECT parent_id
                             from object_object
                             WHERE object_id = obj_asset.object_id )
         ) AS op ON obj_asset.object_id = oo.object_id
    WHERE obj_asset.profile_id = 140 AND obj_asset.rsvp_enabled = 1 AND object.is_published = 1 ORDER BY sort DESC;
    

    The sub query named op is not used in any join or where clause.

    My best guess is that you wanted to to the following:

    SELECT obj_asset.*, object.headline AS title, oo.sort_order AS sort, op.sort_order
    FROM obj_asset 
    JOIN object ON obj_asset.object_id = object.object_id 
    JOIN object_object AS oo on obj_asset.object_id = oo.object_id
    JOIN (SELECT sort_order, o2.object_id
        from object_object as o1
        INNER JOIN object_object as o2 ON o1.object_id = o2.parent_id
        ) AS op ON obj_asset.object_id = op.object_id
    WHERE obj_asset.profile_id = 140 AND obj_asset.rsvp_enabled = 1 AND object.is_published = 1 ORDER BY sort DESC;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi all I have a piece of code which looks like this: public class
I have 2 tables: 1st holds employees (of ones in any position) and the
I have 1st popup, and this 1st popup opens 2nd popup Code: <view-state id=paneMaintenance
I have 3 arrays like this: 1st Array ( [0695] => Array ( [loan_number]
This is the example table: Column | 1st record | 2nd record | 3rd
There are 2 buttons which will generate 2 piece of data. What I need
I am trying to understand how this piece of self-replicating code works (found here
1st i'm newbie I import object/Class using lazy() now my questions are 1) what
1st i have to say that i am not php professional and this is
this is my 1st time posting here, so thanks to everyone who can give

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.