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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:35:06+00:00 2026-06-13T20:35:06+00:00

I can’t figure out a good way of querying this without multiple sub-queries. I

  • 0

I can’t figure out a good way of querying this without multiple sub-queries. I can’t restructure the tables, so that’s not an option. Here’s the setup:

person:
person_id
person_want_id,
person_need_id,
person_ability_id,
person_willingness_id

person_status_types:
status_type_id
status_type_name

Each one of the id’s that are in person is of type person_status_types. What I need to pull out is the status_type_name for each of the id’s in person.

So the return statement would look like this:

person_id | person_want_name | person_need_name | person_ability_name | person_willingness_name

Right now I’m just doing 4 subqueries, but there has to be a cleaner way of doing it. Also, if you want to mention a better database structure, I’m open minded to it for future database production.

  • 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-13T20:35:10+00:00Added an answer on June 13, 2026 at 8:35 pm
    SELECT p.person_id
          ,want.status_type_name AS person_want_name
          ,need.status_type_name AS person_need_name
          ,abt.status_type_name  AS person_ability_name
          ,wil.status_type_name  AS person_willingness_name
    FROM person p
    LEFT JOIN person_status_types want ON p.person_want_id = want.status_type_id
    LEFT JOIN person_status_types need ON p.person_need_id = need.status_type_id
    LEFT JOIN person_status_types abt  ON p.person_ability_id = abt.status_type_id
    LEFT JOIN person_status_types wil ON p.person_willingness_id = wil.status_type_id
    

    Use LEFT JOIN to avoid loosing rows.
    And you can’t single-quote identifiers (like another answer suggests). Single quotes are for values.

    Delimiter for identifier

    Since this has sparked some debate, to clarify once and for all:

    • double quotes " delimit identifiers according to any ANSI standard. This is universally supported by all RDBMS that matter, MySQL being the only exception. You can fix this in MySQL with SET sql_mode = 'ANSI';

      Some RDBMS accept additional alternative delimiters like [] for SQL server.

    • single quotes ' delimit values according to the ANSI standard. Some RDBMS (like MySQL or SQL Server) tolerate them them around column names as general string delimiters. Neither accepts them around table names though.

    • backticks ´ as delimiter for identifiers are a MySQL oddity only. Again, you can fix this in MySQL with SET sql_mode = 'ANSI';

    Here is a list of databases and their respective delimiters for identifiers.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Can any one help me in sorting this out in sed/awk/perl Input file Start
Can anyone help me trying to find out why this doesn't work. The brushes
Can someone help me figure out why my logo image isn't resizing according the
Can anyone enlighten me to a way I can Highlight the content of an
Can anyone explain to me why this program: for(float i = -1; i <
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Can we use javap in our own java code in a programmable way? for
Can MOSS integrate and get user profiles from multiple Active Directory and/or LDAP stores?
Can anyone direct me to a good tutorial on how to set up virtual

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.