I need help to formulate a query. I want to select all DISTINCT colors from TABLE A and TABLE B.
This is the wanted result from the query:
BLACK
RED
YELLOW
BLUE
I have these tables:
TABLE A
ID NAME COLOR
5 SOCKS BLACK
4 SOCKS RED
TABLE B
ID NAME COLOR
0 CAR BLUE
1 BIKE BLUE
5 TRUCK YELLOW
10 PLANE NULL
I have tried:
SELECT DISTINCT A.color FROM A JOIN B ON b.color
But I don’t get all the colors. 🙁
UNION(instead ofUNION ALL) removes duplicates. No need for additional subqueries orDISTINCT.