$pdo = $db->query('SELECT *, GROUP_CONCAT(friends.name, "<br>") AS result FROM animals LEFT JOIN friends ON animals.id=friends.id');
结果:
anna
,fred
我希望得到的结果:
anna
fred
答案 0 :(得分:1)
只需在SEPARATOR
GROUP_CONCAT
即可
$pdo = $db->query('SELECT *, GROUP_CONCAT(friends.name SEPARATOR "<br>") AS result FROM animals LEFT JOIN friends ON animals.id=friends.id');
进一步详情及解释here