我正在处理一个项目,每个组织都有障碍,每个组织可能包含一个或多个障碍,然后我需要生成一个XML文件,显示组织中的每个障碍。
但是执行这个sql代码:
SELECT organizations.*, barriers.barrierName AS bname, barriers.type AS btype, geographs.name AS geo, rpd.rpdname AS rpdn, rpd.meaning AS rpdmean FROM organizations
left join orgbarriers on orgbarriers.idOrg = organizations.id
left join barriers on orgbarriers.idBarrier = barriers.id
left join orggeographs on organizations.id = orggeographs.idOrg
left join geographs on geographs.id = orggeographs.idGeo
left join orgrpds on orgrpds.idOrg = organizations.id
left join rpd on rpd.id = orgrpds.idRPD
我得到了像这张图片一样的重复行:
答案 0 :(得分:0)
使用关键字" DISTINCT"
SELECT DISTINCT rest of your query