Simple idea, difficult implementation for rookie...
Posted: Thu Jul 16, 2009 1:43 pm
Working on my first project in PHP/MySQL. I'm pretty comfortable with searches, updates etc but now I've moved onto a slightly more complicated results listing and I'm having difficulty finding examples that would help.
In a nutshell, I have a very simple database structure; cardset, question and category. A cardset is made up of questions, questions are assigned a category. I can find a user's cardsets and I can edit the information contained about the cardset, ie name, description etc. Now I'd like to find all of the categories that a cardset is made up of. To do that, I need to search the question table with the cardset id, but I would like to return a list of unique occurences of a category id within the questions contained in a cardset. To do that, I need something like this;
SELECT DISTINCT `id_category` FROM `Questions` WHERE `id_cardset` = 8
Now the question, how do I list the results with the category name from each unique occurence of a category id within the question table? I've got to concurrently search the category table to grab the name and list it, no idea how. Thanks!
In a nutshell, I have a very simple database structure; cardset, question and category. A cardset is made up of questions, questions are assigned a category. I can find a user's cardsets and I can edit the information contained about the cardset, ie name, description etc. Now I'd like to find all of the categories that a cardset is made up of. To do that, I need to search the question table with the cardset id, but I would like to return a list of unique occurences of a category id within the questions contained in a cardset. To do that, I need something like this;
SELECT DISTINCT `id_category` FROM `Questions` WHERE `id_cardset` = 8
Now the question, how do I list the results with the category name from each unique occurence of a category id within the question table? I've got to concurrently search the category table to grab the name and list it, no idea how. Thanks!