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?
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?
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;
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.