1

I have a table in MYSQL, with the fields, id, size and color. An example of the data is

    ID      Size     Color
    0       34       Red
    1       34       Blue
    3       38       Green
    4       36       Yellow
    5       38       Red
    6       34       Red

Is there a way in mysql to get the number of all unique records in the table? I.E. There are 2 records that are size 34 and red. I want to pull out the count for all unique combinations in the table.

2 Answers 2

1

To get the count for each combination use

select size, color, count(*) from table group by size, color
Sign up to request clarification or add additional context in comments.

Comments

0

Thinking all id are unique.Try

Select size,color,count(*) from table group by size,color

2 Comments

I was just looking at your answer thinking that it didn't work with the id in the distinct clase. Better after the edit!
Not really sure why you didn't accept the first correct answer but glad you got your answer in the end.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.