Multiple Tables with mysql JOIN -


so i'm wanting amount of time user has spent doing quiz specific course.

here current code.

$study_time = "select sum(time) study_time user_quizzes                         join course_topic_badges on course_topic_badges.id = user_quizzes.badge_id                         join course_topics on course_topic_badges.topic_id = course_topics.id                         join courses on course_topics.course_id = courses.id                         user_id = ".$user_id." , courses.id = ".$subject; 

it feels monstrous query need. there better way either structure database, or run query won't epic?

thanks!

this isn't monstrous, can compress little adding aliases:

$study_time = "select sum(time) study_time user_quizzes uq     join course_topic_badges ctb on ctb.id = uq.badge_id     join course_topics ct on ctb.topic_id = ct.id     join courses c on ct.course_id = c.id     user_id = ".$user_id." , c.id = ".$subject; 

Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -