![]() |
| |||
| We are trying to determine which people have not yet turned in evaluations for particular presentations The evaluation table has the following structure > describe evs; +-----------------+---------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-----------------+---------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | prsn_id | int(11) | NO | | NULL | | | prsntn_id | int(11) | NO | | NULL | | +-----------------+---------+------+-----+---------+----------------+ the presentation table is as follows: mysql> describe prsnttns; +-----------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-----------+--------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | ttl | varchar(255) | YES | | NULL | | +-----------+--------------+------+-----+---------+----------------+ What we want to know is for each person (identified as prsn_id) which evaluations have not yet been turned in. In this case, for a particular presentation id (prsntn_id) we want to know if there exists a row in the ev table for that person (prsn_id), indicating an evaluation was entered. My understanding of joins is quite limited. I can determine which presentations have NO evaluations via the following: select evs.prsn_id,prsntns.id from prsntns left join evs on evs.prsntn_id=prsntns.id where evs.prsn_id is null; but that is not quite what I want. Any suggestions would be appreciated. Tim |
| |||
| On 21 May, 05:54, <t...@tonto.stanford.edu> wrote: > We are trying to determine which people have not yet turned in > evaluations for particular presentations > > The evaluation table has the following structure> describe evs; > > +-----------------+---------+------+-----+---------+----------------+ > | Field | Type | Null | Key | Default | Extra | > +-----------------+---------+------+-----+---------+----------------+ > | id | int(11) | NO | PRI | NULL | auto_increment | > | prsn_id | int(11) | NO | | NULL | | > | prsntn_id | int(11) | NO | | NULL | | > +-----------------+---------+------+-----+---------+----------------+ > > the presentation table is as follows: > > mysql> describe prsnttns; > +-----------+--------------+------+-----+---------+----------------+ > | Field | Type | Null | Key | Default | Extra | > +-----------+--------------+------+-----+---------+----------------+ > | id | int(11) | NO | PRI | NULL | auto_increment | > | ttl | varchar(255) | YES | | NULL | | > +-----------+--------------+------+-----+---------+----------------+ > > What we want to know is for each person (identified as prsn_id) which > evaluations have not yet been turned in. In this case, for a particular > presentation id (prsntn_id) we want to know if there exists a row in > the ev table for that person (prsn_id), indicating an evaluation was > entered. My understanding of joins is quite limited. I can determine > which presentations have NO evaluations via the following: > > select evs.prsn_id,prsntns.id from prsntns left join evs on > evs.prsntn_id=prsntns.id where evs.prsn_id is null; > > but that is not quite what I want. Any suggestions would be appreciated. > > Tim From your description, I do not see that a JOIN is required: SELECT * FROM evs WHERE prsntn_id = x and prsn_id = y |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |