Erika
Erika

Reputation: 429

SQL - Getting category name from SQL table

I have a table in my database where I store order information. Each order has OrderID, CategoryName, ProductName. The CategoryName is for knowing which category each product belongs to.

How would I write a SQL query that gets the categorynames. I have duplicate categoryname in the table, if there are duplicate categoryname, then only one categoryname of that type.

How does a SQL query for that look like?

Any help is very appreciated.

Upvotes: 0

Views: 1299

Answers (2)

Haider Ali
Haider Ali

Reputation: 800

alternatively you can have this syntax as well

SELECT CategoryName 
FROM YourTable
Group BY CategoryName 

Upvotes: 0

Brian Dishaw
Brian Dishaw

Reputation: 5825

SELECT DISTINCT CategoryName 
FROM YourTable

Upvotes: 3

Related Questions