1

I have in my table 3 rows. 2 of them with the same value (valueA) on field status and the 3-rd one with another value (valueB).

What i want to do is to display a message to show me how many rows with the same value exists. Example below:

EX: There are 2 status value in the database There are 1 status value in the database

How can i achive that? Thank you.

2 Answers 2

3

You need group by and count

 select your_column_name, count(*) from your_table 
 group by your_column_name;

in your case assuming status is th column name

select concat("there is " , count(*), "  status in your db") from your_table
group by status;
Sign up to request clarification or add additional context in comments.

Comments

0

You have to use group by, you can learn more about GROUP BY here

In your case query would look something like:

SELECT *, COUNT(*) as `total`
FROM <table>
GROUP BY `status `

Comments

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.