How to select information from a table without duplicate values

1

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.

    
asked by anonymous 03.06.2015 / 19:23

3 answers

1

Just use DISTINCT

SELECT DISTINCT SOBRENOME FROM ALUNOS;
  

Alternatives:   Use% w / w

SELECT SOBRENOME FROM ALUNOS GROUP BY SOBRENOME;
    
03.06.2015 / 19:28
1

Just use distinct

SELECT DISTINCT sobrenome FROM alunos;
    
03.06.2015 / 19:27
0

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.

    
03.06.2015 / 19:27