Jump to content

A puzzle, help!


Yuki

Recommended Posts

Link to create and populate script: http://shahinrostami.com/webdevass2/draft.txt

 

Problem is this:

There are modules, there are tutors.

Tutors teach modules.

 

A module can be taught by more than one tutor, so there are three tables.

 

Tutor (tutorID and their info)

Module(moduleCode and its info)

Teaching(tutorID, moduleCode)  this is a composite key table

 

 

I have a combo box which I fill up with module names, I'm trying to get it to only list those that the tutor ISNT teaching.

 

 

It's not as simple as

 

SELECT module.module_Code, module.module_Name

FROM teaching

RIGHT JOIN module

USING (module_Code)

WHERE tutor_ID !=90000013

GROUP BY module.module_Code;

 

 

 

because of course another tutor may be teaching that module also, so the module is still accounted for. Also this only returns the modules that ARE being taught by someone. If the module currently has no tutors (null after right join) it doesn't include them!

 

help!

Link to comment
https://forums.phpfreaks.com/topic/97458-a-puzzle-help/
Share on other sites

That's not what I'm after

 

 

I need to return the list of modules the teacher does not teach.

 

 

Their are null values in the join, so I need a right join, there are also OTHER tutors with module codes in TEACHING

 

So if it finds

 

63PR2201  9000013

63PR2201  9000011

 

 

it'll != the 9000013 but include 9000011 in the results, see my problem?

 

 

 

 

 

I'm stuck

Link to comment
https://forums.phpfreaks.com/topic/97458-a-puzzle-help/#findComment-498815
Share on other sites

$modulelist = 'SELECT module.module_Code \'module_Codes\', module.module_Name \'module_Name\''

        . ' FROM teaching'

        . ' RIGHT JOIN module'

        . ' USING (module_Code)'

       

        . ' WHERE tutor_ID is null or tutor_ID !=' . $tutor . ''

        . ' GROUP BY module.module_Code;';

 

 

 

Here's what I got so far.

 

 

This shows ALL modules that the TUTOR is not on AND the ones he is (because other tutors are on them)

 

 

Someone must have a big brain hooked up to other brains!

 

Link to comment
https://forums.phpfreaks.com/topic/97458-a-puzzle-help/#findComment-498825
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.