Jump to content

SQL Query Help


jerald717

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.