我使用此代码对设备进行分组,但是当id_material没有设备时,id_material不会显示。
DataSet
我希望它看起来像这样
DataTable
但它只会出现
select
material.id_material,
material.mat_part_number,
group_concat(distinct equipment.equipment_name order by equipment.equipment_name separator ', ') as equipment
FROM material
INNER JOIN equipment_list ON material.id_material=equipment_list.PKid_material INNER JOIN equipment ON equipment_list.PKid_equipment=equipment.id_equipment group by id_material;
我应该在哪里放置NULL条件?
答案 0 :(得分:0)
我刚刚修改了您的查询,这可能会对您有所帮助。
SELECT
material.id_material,
material.mat_part_number,
GROUP_CONCAT(
DISTINCT equipment.equipment_name
ORDER BY
equipment.equipment_name SEPARATOR ', '
) AS equipment
FROM
material
LEFT JOIN equipment_list ON material.id_material = equipment_list.PKid_material
LEFT JOIN equipment ON equipment_list.PKid_equipment = equipment.id_equipment
GROUP BY
id_material;