我已经苦苦挣扎了几个星期,试图弄清楚我如何才能正确地将我的多维数组从连接表构建到我想要的输出中。父数据重复了它的子项...
表
Business
_________
business_id
business_name
Images
___________
image_id
image_path
parent_id (business_id)
QUERY
SELECT business_id, business_name, image_id, image_path parent_id
FROM business LEFT JOIN images ON business_id = parent_id
输出
业务ID:1
business_name:some business_name
图像
image_id:1个
image_path:一些图像路径
parent_id:1业务ID:1
business_name:some business_name
图像
image_id:2
image_path:一些图像路径
PARENT_ID:1业务ID:2
business_name:some business_name
图像
image_id:3
image_path:一些图像路径
parent_id:2
预期产出
业务ID:1
business_name:some business_name
图像
image_id:1个
image_path:一些图像路径
parent_id:1image_id:2个
image_path:一些图像路径
parent_id:1