Query help
-
I’m trying to do a query to display info in a student report card and I can’t figure out how to do it. It looks like the data I need to retrieve is in multiple tables. The data I need to display on the report card is the sum of the number of correct test points for a given course (e.g. Science) for the current wordpress user.
These are the tables and columns I’m working with (I’m not sure if I need to use all of them):
Table: wp_wp_pro_quiz_master that has a column called Name. The data in the Name column is my courses such as Science 7.
Table: wp_wp_pro_quiz_statistic that has a column called correct_count. The value I need to count or sum up in this column is always a value of “1”. (Student get 1 point for a correct answer).
Table: wp_wp_pro_quiz_statistic_ref that has a column called user_id that appears to have the same values/data as the ID column in table: wp_users.
I’ve been trying things similar to this with no luck:
SELECT (count)correct_count, name FROM wp_wp_pro_quiz_statistic, wp_wp_pro_quiz_statistic_ref, wp_wp_pro_quiz_master, wp_users WHERE name LIKE ‘%Science 7% ‘ AND correct_count = ‘1 ‘ AND ID = ‘<?php $current_user->ID ?> ‘;
Can someone advise on how to write this?
Thanks, Sheri
- The topic ‘Query help’ is closed to new replies.