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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:18:23+00:00 2026-06-01T22:18:23+00:00

I only know basic SQL but the project that I am working on uses

  • 0

I only know basic SQL but the project that I am working on uses pretty complex queries. There is one query that I can’t understand. The tables and fields of concern are people and person_details and the executable part of an even dirtier query is:

SELECT people.first_name
    , people.last_name
    , person_statuses.name as person_status
    , companies.name as company_name
    , person_roles.name as role 
    , person_role_memberships.event_name as membership_year
    , person_role_memberships.start_date as start_date
    , person_role_memberships.end_date as end_date
    , person_role_memberships.sponsor_parent_company as sponsor_parent_company
    , person_role_memberships.former_sponsor_parent_company as former_sponsor_parent_company
    , person_role_memberships.workshop as workshop
FROM people
    , *person_details as business_details*
    , *person_details*
    , person_roles
    ,  person_role_memberships
    , companies
    , person_statuses
    , companies as parent_companies
WHERE person_role_memberships.person_id = people.id 
    AND person_role_memberships.person_role_id = person_roles.id 
    AND 

    business_details.type = 'BusinessDetail' 
    and business_details.person_id = people.id 
    AND person_details.type = 'PersonalDetail' 
    and person_details.person_id = people.id 

    AND people.person_status_id = person_statuses.id 
    AND ifnull(companies.parent_id, companies.id) = parent_companies.id  
    AND people.company_id = companies.id 
    AND companies.name = 'Pak Qatar' 
    AND people.last_name = 'Aslam' 
limit 100;

I want to know what is the logic that the bold part of the where clause is creating. Is it, because of the AND keyword, only allowing those persons, which have BusinessDetail as well as PersonalDetails is the person_details table?

  • 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-01T22:18:24+00:00Added an answer on June 1, 2026 at 10:18 pm

    It’s basically saying:

    The person MUST have a business_details record which MUST be of type ‘BusinessDetails’ AND the person MUST have a person_details record which MUST be of the type ‘PersonalDetail’ It looks like both are stored in the same table (business_details is an alias of the person_details table), so its joining to the table twice to check for both conditions.

    I’m not sure what flavour of SQL this is (SQL Server/Oracle etc) but the query could probably be written out a little neater using proper join syntax (although the syntax used will create joins under the hood, its not as easy to read as something with explicit join syntax).

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

Sidebar

Related Questions

I only know basic concepts for multi-threading, and I currently encounter a situation that
Very basic, but didn't know what this type of query is called...I want a
I KNOW that this is basic. But I'm so JS-retarded I can't do-it-myself and
I've made a local database for a C# project: I know basic SQL commands,
I only know of one way: Right click and click 'delete me' How else
I only know that the difference between hashmap and map is that hashmap is
Is there any way to find out diagonals of quadrilateral if I only know
I want to do some sophisticated animations. But I only know how to animate
I need to read a file in PHP, but I only know the end
I only want facts as far as possible. There are some things that ASP.Net

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.