Let's say I have a table named ALUNOS
, with 3 columns, ID
, NAME
, SOBRENOME
And I want to get all the names, but in a way that does not double if one student has the same surname as another student.
Let's say I have a table named ALUNOS
, with 3 columns, ID
, NAME
, SOBRENOME
And I want to get all the names, but in a way that does not double if one student has the same surname as another student.
Just use DISTINCT
SELECT DISTINCT SOBRENOME FROM ALUNOS;
Alternatives: Use% w / w
SELECT SOBRENOME FROM ALUNOS GROUP BY SOBRENOME;
Just use distinct
SELECT DISTINCT sobrenome FROM alunos;
For this you just have to do the following:
SELECT DISTINCT (NOME) FROM TABELA;
So, only one name will come if there are several of them.