我可以在尝试进行数据库查询时使用帮助。我有一个包含单词或短语,产品ID,语言ID和版本ID的表。 version_id是用逗号分隔的列,因为同一单词可以在多个版本中使用,并且我尝试避免添加具有相同数据的另一行(不同版本除外)。
我正在尝试获取每种产品,版本和语言的字数。我遇到的问题是分隔version_id,因为它是逗号分隔的列。有没有办法分别获取版本1和版本2中所有单词的计数?
我目前有此查询,该查询有效,但它不会按版本分隔在逗号分隔的列中。
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