Reputation: 5016
My table is:
title type
a category
b category
d tag
a category
c tag
r tag
t category
d category
I am trying to select unique values for each (category and tag)
How would I merge these 2 queries?
SELECT DISTINCT title, type FROM table WHERE type='category'
SELECT DISTINCT title, type FROM table WHERE type='tag'
Upvotes: 0
Views: 29
Reputation: 1
It can be done with "group by" which find the unique combinations
select title, type
from table
group by title, type;
Upvotes: 0
Reputation: 1270873
Actually, this would seem to do what you want:
select distinct title, type
from table
where type in ('category', 'tag')
order by type;
I added the order by so the type
s are all together.
Upvotes: 1