T
thiago.ferrari
Hi! I have a query that displays the value "Descartados.Cod_animal" as
many times as "Sugestão.Cod_animal" matchs the conditions. What I want
is that the query shows me only one record per "Descartados.Cod_animal"
and discards the rest of records that matchs the conditions.
Example (NOW):
Descartados.Cod_animal | Sugestao.Cod_animal
6 2
6 8
6 5
7 2
7 8
7 5
Example (WHAT I WANT):
Example (NOW):
Descartados.Cod_animal | Sugestao.Cod_animal
6 2
7 8
Did I make myself clear?
Code:
SELECT Descartados.Cod_animal, Descartados.Tipo AS Descartados_Tipo,
Descartados.Sexo, Sugestao.Cod_animal AS Sugestao_Cod_animal,
Sugestao.Tipo AS Sugestao_Tipo, Sugestao.Sexo
FROM Sugestao, Descartados
WHERE (((Descartados.Tipo)=2 Or (Descartados.Tipo)=3) And
((Sugestao.Sexo)=Descartados.Sexo));
many times as "Sugestão.Cod_animal" matchs the conditions. What I want
is that the query shows me only one record per "Descartados.Cod_animal"
and discards the rest of records that matchs the conditions.
Example (NOW):
Descartados.Cod_animal | Sugestao.Cod_animal
6 2
6 8
6 5
7 2
7 8
7 5
Example (WHAT I WANT):
Example (NOW):
Descartados.Cod_animal | Sugestao.Cod_animal
6 2
7 8
Did I make myself clear?
Code:
SELECT Descartados.Cod_animal, Descartados.Tipo AS Descartados_Tipo,
Descartados.Sexo, Sugestao.Cod_animal AS Sugestao_Cod_animal,
Sugestao.Tipo AS Sugestao_Tipo, Sugestao.Sexo
FROM Sugestao, Descartados
WHERE (((Descartados.Tipo)=2 Or (Descartados.Tipo)=3) And
((Sugestao.Sexo)=Descartados.Sexo));