Jump to content

Need a count of comma seperated numbers - Simple (I think)


izbryte

Recommended Posts

I have a field in my MySQL DB that holds numbers separated by a comma (example: 1, 3, 45, 137, 87). I simply want to get a count of how many numbers are in there. (Using my example the result would be 5). I'm sure this is a simple question but I don't know how. I'm able to extract the numbers but I can't get the count to read anything other than 1. Can anyone help?

The easiest way is to explode the result in PHP and count the number of elements in the array, not so sure that's the most efficient.  I'm also not sure there is an elegant way to do it in SQL.  Did a quick search and found a couple hacky solutions.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.