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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:03:39+00:00 2026-06-12T21:03:39+00:00

I am trying to pull students and the courses they are registered for from

  • 0

I am trying to pull students and the courses they are registered for from a mysql database. I want to replace the course id with the course name in the output.

I have these tables and columns:

table: users_to_courses
columns: users_LOGIN and courses_ID

table: users
columns: login, name and surname

table: courses
columns: id and name

The tables tie together on the following:

users_to_courses.users_LOGIN = users.login 
users_to_courses.courses_ID = courses.id

I am trying to get output of surname, name, courses (by name and not id) so it would look like Smith, John Chemistry, Physics, Composition

Here is what I am trying unsuccessfully:

SELECT
users.surname,
users.name,
users.login,
users_to_courses.users_LOGIN,
(select group_concat (courses.name) from courses
where users_to_courses.users_LOGIN = users.login and users_to_courses.courses_ID =    
courses.id
GROUP BY users.surname) as courses
from courses join users_to_courses
on courses.id = users_to_courses.courses_ID
  • 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-12T21:03:41+00:00Added an answer on June 12, 2026 at 9:03 pm

    Try this

    Select
    
        u.surname,
        u.name,
        u.login,
        uc.users_LOGIN,
        c.Name,
    
        --added this line
        group_concat (c.name)  
    From users_to_courses uc
    JOIN users u ON uc.users_LOGIN = u.login 
    JOIN courses c ON uc.courses_ID = c.id
    
    -- added this line
    GROUP BY u.surname, u.name, u.login, uc.users_LOGIN
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to pull from the database a saved Title. I want it
I'm trying to pull out information from a database with PHP and have the
I'm trying to pull data from the YouTube API into a local MySQL table.
I'm trying to pull a username from a sql database to place on my
I'm trying to pull the students that are tardy for the previous period from
I am trying to pull at list of resource/database names and IDs from a
I'm trying to pull some results from a database but I guess I'm kind
I am trying to pull the status updates from a Facebook Page. I have
Trying pull the database from Hekoku to local but failed. heroku db:pull postgres://root:@localhost/db_name Admittedly,
I'm trying to pull some data from MySQL using an Array that was fetch

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.