2 回答
TA贡献1775条经验 获得超11个赞
完美,这就是我想要的,非常感谢!
这里是修改后的代码:
SELECT *,
GROUP_CONCAT(DISTINCT petName ORDER BY petName) AS petsNames
FROM clients
LEFT JOIN owners ON owners.idClients = clients.idClients
LEFT JOIN pets ON pets.idPets = owners.idPets
LEFT JOIN clientsdocs ON clientsdocs.idClients = clients.idClients
WHERE clients.idClients='$id'
TA贡献1864条经验 获得超6个赞
您可以更改查询,例如:
SELECT
clients.*,
GROUP_CONCAT(petName) AS petsNames # implode pets names s into 1 string
FROM clients
LEFT JOIN owners ON owners.idClients = clients.idClients
LEFT JOIN pets ON pets.idPets = owners.idPets
LEFT JOIN clientsdocs ON clientsdocs.idClients = clients.idClients
GROUP BY clients.idClients # this is group all client's data in single row
WHERE clients.idClients='$id';
这不是解决方案,但可以为您提供最佳解决方案的想法。
- 2 回答
- 0 关注
- 98 浏览
添加回答
举报