jerald717 Posted February 15, 2011 Share Posted February 15, 2011 Hi, I have a question. I performed an INNER JOIN on 2 tables, with tutor_id as key. the tutor_overall_level_subject table records tutor_ids with subject_level_ids, and it is a one-to-many relationship (i.e. 1 tutor could have 'chosen' many subjects). SELECT * FROM `tutor_overall_level_subject` INNER JOIN `tutor_profile` AS tp WHERE `subject_level_id` LIKE 1 OR `subject_level_id` LIKE 2 Part 1: The above-mentioned query returns rows with repeated information (i.e. tutor A could have chosen subjects 1 and 2--in which case tutor A's information is displayed twice). Is there any way for me to re-write this query to pull out tutor information only once? Part 2: I also want to modify the query to display the exact choices that the tutor makes (i.e. if tutor A had chosen subjects 1, 2 and 3 , this query wouldn't pull his information out. If he had chosen subjects 1 AND 2, this query should pull his information out. if tutor A had only chosen subject 1, his information wouldn't show). Thanks for all the help. Link to comment https://forums.phpfreaks.com/topic/227710-sql-query-help/ Share on other sites More sharing options...
kickstart Posted February 16, 2011 Share Posted February 16, 2011 Hi Might be best to use GROUP_CONCAT to build up a single field containing all the subjects from tutor_profile. All the best Keith Link to comment https://forums.phpfreaks.com/topic/227710-sql-query-help/#findComment-1174957 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.