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

  • Home
  • SEARCH
  • 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 5984875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:26:39+00:00 2026-05-22T22:26:39+00:00

I don’t think this is a duplicate posting because I’ve looked around and this

  • 0

I don’t think this is a duplicate posting because I’ve looked around and this seems a bit more specific than whats already been asked (but I could be wrong).

I have 4 tables and one of them is just a lookup table

SELECT exercises.id as exid, name, sets, reps, type, movement, categories.id
FROM exercises
INNER JOIN exercisecategory ON exercises.id = exerciseid
INNER JOIN categories ON categoryid = categories.id
INNER JOIN workoutcategory ON workoutid = workoutcategory.id
WHERE (workoutcategory.id = '$workouttypeid')
AND rand_id > UNIX_TIMESTAMP() 
ORDER BY rand_id ASC LIMIT 6;

exercises table contains a list of exercise names, sets, reps, and an id

categories table contains an id, musclegroup, and type of movement

workoutcategory table contains an id, and a more specific motion (ie: upper body push, or upper body pull)

exercisecategory table is the lookup table that contains (and matches the id’s) for exerciseid, categoryid, and workoutid

I’ve also added a column to the exercises table that generates a random number upon entering the row in the database. This number is then updated only for the specified category when it is called, and then sorted and displays the ascending order of the top 6 listings. This generates a nice random entry for me. (Found that solution elsewhere here on SO).

This works fine for generating 6 random exercises from a specific top level category. But I’d like to drill down further. Here’s an example…

select all rows inside categoryid 4

then still within the category 4 results, find all that have movementid 2, and then find one entry with a typeid 1, then another for typeid 2, etc

TLDR; Basically there’s a few levels of categories and I’m looking to select a few from here and a few from there and they’re all within this top level. I’m thinking this could all be executed within more than one query but im not sure how… in the end I’m looking to end with one array of the randomized entries.

Sorry for the long read, its the best explanation I’ve got.

  • 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-22T22:26:39+00:00Added an answer on May 22, 2026 at 10:26 pm

    Just realized I never came back to this posting…

    I ended up using several mysql queries within a switch based on what is needed during the request. Worked out perfectly.

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

Sidebar

Related Questions

Don't think this is a repost, difficult to search for the word between because
Don't think my virtualhost is working correctly. This is what I have inside of
Don't know if this is an eclipse specific problem but whenever I declare a
Don't ask me why but i can't use this method because I need to
Don't immediately flag me for a duplicate question. My issue is different because I
don't know what happened in my jcrop selection. I think I pressed some keys
Don't dismiss this as a newbie question! It's not, I'm not, I've tried everything,
I don't know why, but this code worked for me a month ago... maybe
(Don't know if this is strictly on-topic, but I don't see any better Stack
Don't know if this has been asked before, so point me to another question

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.