How to make a select in the bank to not bring repeated values?

2

For example you have in the table the values: green, red, blue, blue, pink, pink, pink, yellow. I would need to return from the table colors only once blue and pink. Do you have any way to do this?

    
asked by anonymous 14.07.2015 / 19:33

2 answers

7

Use DISTINCT will return without repeating:

SELECT DISTINCT cor FROM Cores;

Another unorthodox solution would be to use GROUP BY:

SELECT DISTINCT cor FROM Cores GROUP BY cor;
    
14.07.2015 / 19:36
3
SELECT DISTINCT cor, outra_coluna_se_quiser FROM cores;

The secret there is DISTINCT . It selects only the rows in a single way, without repeating the column value.

Documentation . Optimization .

    
14.07.2015 / 19:36