0

I have problem to get count of the same values on each row cause separated values.

This is mytable in phpMyAdmin

My question is: how to get only one value and get count on each row?

In this picture given, I want the result like this:

The count of data '4' on each table row is 3.

If i select another value like 1:

The count of data '1' on each table row is 2.

I hope for your help. Thank you.

Your Common Sense
  • 156,878
  • 40
  • 214
  • 345

1 Answers1

1

You can use find in set like this

SELECT count(id) FROM `test` WHERE FIND_IN_SET(5, mydata)

https://www.w3resource.com/mysql/string-functions/mysql-find_in_set-function.php

Shibon
  • 1,552
  • 2
  • 9
  • 20