parixit
parixit

Reputation:

Selecting unique entries from a column

I have this table ID | Category | Subcategory |

           1  |      Books       |    Comic         |
           2  |      Books       |   Fiction        |
           3  |      Cars        |     New          |
           4  |      Books       |   Non- fiction   |
           4  |      Cars        |    Second hand   |

and I want to select only unique entries from the column 'Category'. That is, I want 'Books' and 'Cars' to be selected only once. How can I write a query ?? Help please.

Upvotes: 1

Views: 180

Answers (2)

Goran
Goran

Reputation: 6846

Or group by

SELECT Category
FROM Table
GROUP BY Category

Group by enables you to retrieve various aggregates based on your query (such as number of items in category etc...)

Upvotes: 1

Julian de Wit
Julian de Wit

Reputation: 3094

You mean distinct ?

SELECT Distinct Category
FROM Table

Upvotes: 3

Related Questions