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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:29:53+00:00 2026-05-26T10:29:53+00:00

So I have 2 tables in my database, they are ‘workouts’ and ‘exercises’. Workouts

  • 0

So I have 2 tables in my database, they are ‘workouts’ and ‘exercises’. Workouts contains a row called exercises which is a comma-separated list of exercise IDs – from the ‘exercises’ table e.g. ‘1,2,3’.

My question is, can I write a single query to allow me to select a row from the workouts table, say one with an id of 1, and have MySQL fetch each of the exercises from the list in that row, returning them within the ‘workout’ row?

At the moment I’m using PHP to select the workout row, and then making individual requests for each of the exercises, resulting in serious inefficiency.

I took a look at Joining rows as array from another table for each row and also did some research into the group_concat() function, but I’m not sure that’s what I’m after.

Update
Here are the 2 tables:
enter image description here

  • 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-26T10:29:53+00:00Added an answer on May 26, 2026 at 10:29 am

    IMO, the best approach is to redesign your schema to have a cross-reference table called exercises_workouts (or something similar). Remove the CSV field.

    Here’s page that goes into more detail on implementing a many-to-many relationship:

    http://www.tonymarston.net/php-mysql/many-to-many.html

    Note: The linked page uses the mysql_* functions, but the general explanation of the approach stands. You’ll want to look into PDO for database access.

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

Sidebar

Related Questions

I have two tables in the database one contains a list of all possible
I have 3 database tables, all of them have the same 5 columns. They
i have in the database typical tables like user, usergroup, and they have relations.
I have a database with two tables ( Table1 and Table2 ). They both
I have a database with two main tables notes and labels . They have
I have two tables in my database, table1 and table2. They are identical. But
I have two tables in my database: test1 which looks like: ID pubmed_ID -------------------
Excuse the long question! We have two database tables, e.g. Car and Wheel. They
I am designing the database (MySQL) in which I have two tables Employees and
I have three tables in my SQL 2008 database: User, CutomerUser and SalesUser. They

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.