In a query like this:
SELECT GROUP_CONCAT(DISTINCT( p.products_id )) AS comma_separated
FROM products p
left join specials s
ON p.products_id = s.products_id
left join products_to_categories p2c
ON p.products_id = p2c.products_id
left join products_description pd
ON p.products_id = pd.products_id
inner join products_attributes pa
ON p.products_id = pa.products_id
WHERE p.products_status = '1'
AND p2c.categories_id = 57
AND Date_sub(Curdate(), interval 7000 day) <= p.products_date_added
ORDER BY p.products_id DESC
I am getting a result of long list of comma separated numbers in a field named comma_separated. How can I modify the query to count how many comma separated values there are?
EDIT:
Thanks, Barmar for the answer below. I kept on getting a much shorter list of numbers (107 values instead of 4000+ in the actual count), and now I finally found the cause. It seems GROUP_CONCAT is limited to 1024 characters, which is quite bad for my application. Source: http://www.bennadel.com/blog/2669-mysql-group-concat-fails-silently-when-it-hits-its-size-limit.htm