sql query in mysql shows repeated records

0

I have a query in which I want to get the name of a course when a field is different the problem is that it shows me repeated records know what the problem could be. the query should only show courses that you do not have assigned

tables

============= sql query ============================================== =======

 SELECT CG.NOMBRE_CURSO 
 FROM curso_generico_relator cgr,curso_generico cg,relatores r
 where not cgr.RUT_RELATOR='23.709.392-5' 
 and cgr.ID_CURSO=cg.ID_CURSO
 and cgr.RUT_RELATOR=r.RUT_RELATOR

=========================== ====================================== ===================

    
asked by jose miguel jara 16.04.2017 в 22:11
source

1 answer

1

With the query that you indicate what you are asking are all the combinations that exist in curso_generico_relator that do not correspond to rut_relator = '23.709.392-5' . Because of the result you get, it is clear that there are courses that are related to more than one speaker.

If what you want is to obtain the list of courses that a rapporteur does not have assigned to you then you can obtain it with your query by adding the operator DISTINCT or with a query that uses the operator NOT IN :

select
    nombre_curso
from
    curso_generico
where
    id_curso not in (
        select
            id_curso
        from
            curso_generico_relator
        where
            rut_relator = '23.709.392-5'
    )
    
answered by 18.04.2017 / 17:40
source