Hi guys i have a table with this data
______________
| site | cat |
______________
| my | sp |
| my | sp |
| my | cc |
| my | cc |
| yo | sp |
| yo | sp |
| yo | cc |
| yo | cc |
______________

my question is this:
what query will give me this result
______________
| site | cat |
______________
| my | sp |
| my | cc |
| yo | sp |
| yo | cc |
______________
i am very new to sql and relational database although very good in nosql databases.
i have also spent more than 3hours searching the net for answers but have got non.

From your example it looks like you want the distinct values from the table

SELECT DISTINCT COL_NAME1, COL_NAME2 FROM...

But I doubt that is it. What exactly do you need?

Use distinct keyword? Sample

Member Avatar for diafol

If those columns are the extent of your fields in the table, why allow duplicates in the first place? In any event, you may be better off storing the ids (maybe integers) if these fields are foreign keys.

I think the problem is the way I designed my table it is all wrong thanks guys it feels good to have friends who will help if even they can't thanks this is a family

SELECT site, DISTINCT cat FROM tablename;
Change tablename to the name of table you are using.

Thanks guys i have solved it
the answer which is in it self another question is posted here

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.