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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T09:08:01+00:00 2026-06-02T09:08:01+00:00

I am using mysql. I have two tables Students: stud_num prof1 prof2 Prof prof_id

  • 0

I am using mysql.

I have two tables

Students:
stud_num 
prof1
prof2

Prof
prof_id
first_name
last_name

Prof Id is a foreign key in the students table.

I want to get the stud_num and prof1 as first and last name and prof2 as first and last name

Here is my query that doesn’t work:

select s.stud_num, CONCAT(p.first_name, " ", p.last_name) as PROF1, CONCAT(p.first_name, " ", p.last_name) as PROF2
from students s
inner join prof p
on s.prof1 = p.prof
and s.prof2 = p.prof

This does not work. Is there an easy way to do this???

  • 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-02T09:08:02+00:00Added an answer on June 2, 2026 at 9:08 am

    Join TWICE to the professors table, but I would suggest LEFT join in case one of the professor’s IDs is not provided

    select 
          s.stud_num, 
          CONCAT(p1.first_name, " ", p1.last_name) as PROF1, 
          CONCAT(p2.first_name, " ", p2.last_name) as PROF2
       from 
          students s
             LEFT join prof p1
                on s.prof1 = p1.prof
             LEFT join prof p2
                on s.prof2 = p2.prof
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

using php and mysql I have two tables, a users table and a profiles
I'm using PHP/MySql. If I have two tables (hypothetically) as follows: id name and
using mysql and php, I have two tables, I'm french so the table names
I have two tables: student Columns first_name last_name teacher_accounts Columns fname lname I have
I am using MySQL and I have two tables: master_table ORDERNO ITEM QTY stock_bal
I have two tables connected by a foreign key with a one to many
I am using the latest MySQL. I have two tables: backlinks and pages .
I am using PHP and MySQL. I have two tables, one for customers, and
I am using Mysql. And I have two tables which are one-to-one related with
I have a database using MySQL 2005. I have two tables, Enrolment and AlertMsg.

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.