I could use help with the database query I am trying to pull off. I have a table that has a word or phrase, a product id, a language id, and a version id. The version_id is a comma separated column, since the same word can be used in multiple versions and I tried to avoid adding another row with same data except for a different version.
The table currently looks like this
I am trying to get the COUNT of word per product, version, and language. The problem I am getting is seperating the version_id since it is a comma seperated column. Is there a way to get the count for all words in version 1, and version 2, separately?
I currently have this query, which works, but it does not separate by versions in a comma separated column.
SELECT COUNT( translation ) AS translations, fdp.name AS product, fdv.name AS version, fdl.name AS language, fdl.position
FROM `fdnfortidictionary_dictionary` AS `fdd`
LEFT JOIN `fdnfortidictionary_product` AS `fdp` ON fdd.product_id = fdp.id
LEFT JOIN `fdnfortidictionary_version` AS `fdv` ON fdd.version_id = fdv.id
LEFT JOIN `fdnfortidictionary_language` AS `fdl` ON fdd.language_id = fdl.id WHERE fdp.enable = 1
AND fdd.product_id IN (1,2)
AND CONCAT( ",", fdd.version_id, "," ) REGEXP ",(1|2|3|4|5),"
GROUP BY `language`,`version`,`product`,`position`
ORDER BY fdl.position ASC