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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T15:51:09+00:00 2026-05-24T15:51:09+00:00

Quick question. feel like a noob but haven’t found the right syntax for this

  • 0

Quick question. feel like a noob but haven’t found the right syntax for this yet.

Have 3 tables.

T1-
AsessessmentID(auto Incr)
inspectorID,
assistantID,
plant name

T2-
UserID(auto Incr),
username,
name

T3-
plantID(auto Incr)
PlantName

Basically I want to have a php/mysql table that is very similar to T1 but instead of listing the ID’s I would like the names. Heres my call so far:

SELECT DISTINCT a.AssessmentID, u.Name, a.PlantAssistID, p.PlantName 
                FROM assessmentscores AS a, user AS u, plant AS p
                WHERE u.userID=a.InspectorID AND u.Name='$name' AND p.PlantID=a.Plant

This works as u.Name will give me the name for the inspector but I can’t figure out how to call the second (a.PlantAssistID). Just keep getting the same name for both.

What call to the server should I use to return two different names. Any help would be appreciated

  • 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-24T15:51:10+00:00Added an answer on May 24, 2026 at 3:51 pm

    First things first: if you want to select from the assessment table and augment the resultset using the other tables, think about using LEFT JOIN. If you want a more restrictive result, where only assessments are returned that are actually associated with existing users, use an INNER JOIN instead. The example below uses LEFT JOIN.

    Not sure whether this is what you want exactly, but you can try:

    SELECT a.AssessmentID as a_id, u.Name as u_name, a.PlantAssistID as a_plantassistid, p.PlantName as p_plantname, uass.Name as u_ass_name
        FROM assessmentscores a
        LEFT JOIN user u ON u.UserID = a.AssessmentID
        LEFT JOIN plant p ON p.PlantID = a.Plant
        LEFT JOIN user uass ON uass.UserID = a.PlantAssistentID
    

    Result:

    array(
        'a_id'            => int    /* AssessmentID */
        'u_name'          => string /* User name */
        'a_plantassistid' => int    /* Assessment.PlantAssistID */
        'p_plantname'     => string /* Plant name */
        'u_ass_name'      => string /* The user name of the user with assistent_id */
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I feel like this question has been asked many times, but the solution is
Quick question about the TransactionScope object. Found this on the internet: When you access
Quick question that requires a long explanation.. Say I have two tables - one
this is a quick question: I have this Database Project in a Web app
I know this is a classic interview question, but here is my quick attempt
I feel a little silly asking this question, but from everything I've read, this
Quick question. What do you think, I have a few sites that use a
Quick question regarding CSS and the browser. I tried searching SO and found some
Quick question! Does putting a clear element INSIDE a floated div do anything? Like:
Quick question: is this kind of nesting possible? An if statement first passing a

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.