【发布时间】:2021-07-14 16:55:19
【问题描述】:
我得到这个错误:
“错误 1242 超过 1 行”
即使我已经使用 group_concat ..
这是我的查询,它给了我错误
SELECT
`coms_participant_exam_event`.`coms_exam_event_id` AS PEE_ID,
(SELECT GROUP_CONCAT((SELECT CONCAT(`bpmspace_coms_v1`.`state`.`name`," (",`coms_participant_exam_event`.`state_id`,") ", count(`coms_participant_exam_event`.`state_id`))
FROM `coms_participant_exam_event`
JOIN `bpmspace_coms_v1`.`state` ON
(
`bpmspace_coms_v1`.`state`.`state_id` =
`bpmspace_coms_v1`.`coms_participant_exam_event`.`state_id`
)
where `coms_exam_event_id` = `coms_participant_exam_event`.`coms_exam_event_id`
group by `bpmspace_coms_v1`.`coms_participant_exam_event`.`state_id`) , ','))
FROM `coms_participant_exam_event`
group by `coms_participant_exam_event`.`coms_exam_event_id`
当我用一个 id “硬编码”coms_exam_event_id 时,它只有 1 行,因为它正在工作 - 不知道为什么 GROUP_CONCAT 不够
SELECT
`coms_participant_exam_event`.`coms_exam_event_id` AS PEE_ID,
(SELECT GROUP_CONCAT((SELECT CONCAT(`bpmspace_coms_v1`.`state`.`name`," (",`coms_participant_exam_event`.`state_id`,") ", count(`coms_participant_exam_event`.`state_id`))
FROM `coms_participant_exam_event`
JOIN `bpmspace_coms_v1`.`state` ON
(
`bpmspace_coms_v1`.`state`.`state_id` =
`bpmspace_coms_v1`.`coms_participant_exam_event`.`state_id`
)
where `coms_exam_event_id` = 877523
group by `bpmspace_coms_v1`.`coms_participant_exam_event`.`state_id`),','))
FROM `coms_participant_exam_event`
group by `coms_participant_exam_event`.`coms_exam_event_id`
感谢您的帮助 抢
【问题讨论】:
标签: sql mariadb subquery group-concat