我有以下子查询:
SELECT GROUP_CONCAT(tb5403_matrix_header.tb5403_name_ru)
FROM tb5403_matrix_header
WHERE tb5403_matrix_header.tb5403_id IN
(tb0201_tb5403_ids)
GROUP BY tb5403_matrix_header.tb5403_id
字段tb0201_tb5403_ids
包含以逗号分隔的数字:
10,2,4
5,8,7等。
但是,mysql只选择字段的第一个元素:
10
5
任何帮助人员!
答案 0 :(得分:0)
根据axiac的评论 - 尝试FIND_IN_SET:
SELECT GROUP_CONCAT(tb5403_matrix_header.tb5403_name_ru)
FROM tb5403_matrix_header
WHERE
FIND_IN_SET(tb5403_matrix_header.tb5403_id, tb0201_tb5403_ids) != 0
GROUP BY tb5403_matrix_header.tb5403_id