-3

If my table looks like this

id -  car  - color
1  -  BMW  - red
2  -  JAG  - blue
3  -  JEEP - pink
4  -  MERC - blue
5  -  BMW  - black
6  -  BMW  - black
7  -  BMW  - black
8  -  BMW  - black
9  -  BMW  - black
10 -  JEEP - pink
11 -  JEEP - pink
12 -  JEEP - pink
13 -  JEEP - pink
14 -  JAG  - blue
15 -  JAG  - blue
16 -  JAG  - blue
17 -  JAG  - blue
18 -  MERC - blue
19 -  MERC - blue

What query should I write so my response is [bmw, Jag, jeep, Merc] Meaning that only one of them gets picked?

I tried something like

SELECT * FROM entries WHERE client UNIQUE

but I know that it's super wrong

Spectric
  • 30,714
  • 6
  • 20
  • 43

1 Answers1

0

You are looking for the SELECT DISTINCT statement. The SELECT DISTINCT statement is used to return only distinct (different) values. Read more about SELECT DISTINCT here.

SELECT DISTINCT car FROM entries; 

UNIQUE is a constraint used while creating schemas. You can read more about UNIQUE here

Read more here

Cody
  • 467
  • 2
  • 11