I have a Jdatabase
table having a comma separated field. What would be the best way (according to Joomla coding standards) to count the number of elements separated by commas. Like in the case below :
id
comma separated values
01
(2,5,6,7,8,9,21,24,28)
It should return : 9
If I am not wrong, one of the ways to achieve it using mysql
would be this :
SELECT (LENGTH(column_name) - LENGTH(REPLACE(column_name,",","")) + 1) AS MyColumnCounts
FROM table_name;
But is this the best way?
Help would be appreciated.