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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:57:29+00:00 2026-06-07T10:57:29+00:00

I have 2 tables. workers and experience In table workers there is row worker_parent

  • 0

I have 2 tables.

workers and experience

In table workers there is row worker_parent (because one worker can be responsible for other).

No I must connect tables like that:

SELECT w1.* FROM workers w1 LEFT JOIN workers w2 ON (w2.id = w1.worker_parent)

And that’s ok. But I have to order by experience of w2 and I try to add table experience but it’s connect to w1 and not to w2.

My question is how to add table experience (which has row worker_id) to w2 and order by experience AND SELECT data from w1.

This is my try.

SELECT w1.* FROM workers w1 LEFT JOIN workers w2 ON (w2.id = w1.worker_parent) LEFT JOIN experience e ON (w2.id = e.worker_id) ORDER BY e.experience DESC

Thank’s for help

  • 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-07T10:57:31+00:00Added an answer on June 7, 2026 at 10:57 am

    if you only want child workers that have a parent with experince,
    you need to add a where (or change join type)
    (for readability i renamed w1 and w2 to w_child and w_parent)

    SELECT w_child.*, e_parent.experience
    FROM workers AS w_child 
    LEFT JOIN workers AS w_parent ON (w_parent.id = w_child.worker_parent) 
    LEFT JOIN experience AS e_parent ON (w_parent.id = e_parent.worker_id) 
    WHERE e_parent.worker_id IS NOT NULL
    ORDER BY e_parent.experience DESC
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three tables: User, Employee and Worker. User table has one-to-zero-or-one relationship with
Is there a way to have multiple delayed_job workers updating to the same table?
I am using the entity framework. I have workers table: Worker(workerId, name, statusId) I
I have three tables, one is tasks which are tasks that factory workers complete
I have thus two tables: CREATE TABLE `workers` ( `id` int(7) NOT NULL AUTO_INCREMENT,
I have a SQL DB that is just one table with one row that
I have two tables: Companies: (id, name) Workers: (id, name, country) I would like
Here is my problem - I have 2 tables: WORKER, with columns |ID|OTHER_STAF| ,
I have tables linked by FK, I query on the first table using entity
I have two tables: Companies: (id, name, city) Workers: (id, name) I would like

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.