Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.