sql中1对多关系,将子表name组合追加到主表中

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_24606505/article/details/80435282

1,其中YJ_reports关联多个YJ_check_items,现在需将item的name组合起来追加在reports后面

SELECT

report.*, (
SELECT
group_concat(items. NAME)
FROM
YJ_check_items AS items
WHERE
items.report_id = report.id
) AS items
FROM
YJ_reports AS report
LIMIT 1000

猜你喜欢

转载自blog.csdn.net/qq_24606505/article/details/80435282