Tables are as follows:
grades
gr_id | gr_name
1 pre-school
2 Grade 1
… …
product
pr_id | pr_name | pr_url
1 Activity activity.swf
2 Weather weather.swf
…
product_grades
pg_id | pg_product | pg_grade
1 1 2
2 2 1
…
I need the output to be the following
Activity Book Pre-school, Grade 1, kindergarten
Weather Maker Grade 5, Grade 4, Grade 3
Without the product name being printed out more than once
I have this sql statement but it print out product names for each grade instead of just one product name and multiple grades
Activity Book Pre-school
Activity Book Grade 1
Activity Book Kindergarten
Weather Maker Grade 5
Weather Maker Grade 4
Weather Maker Grade 3
$sql=“SELECT product.pr_id, product.pr_name, product_grades.pg_grade, product_grades.pg_product, grades.gr_id, grades.gr_name FROM ( product INNER JOIN product_grades ON product.pr_id = product_grades.pg_product ) INNER JOIN grades ON product_grades.pg_grade=grades.gr_id ORDER BY product.pr_name”;
Help would be appreciated.
Thanks for any help given.