如何为 group_concat 使用分隔符?
How can I use a seperator for group concat?
$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
只需要在GROUP_CONCAT
中指定SEPARATOR
$pdo = $db->query('SELECT *, GROUP_CONCAT(friends.name SEPARATOR "<br>") AS result FROM animals LEFT JOIN friends ON animals.id=friends.id');
更多细节和解释here
$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
只需要在GROUP_CONCAT
SEPARATOR
$pdo = $db->query('SELECT *, GROUP_CONCAT(friends.name SEPARATOR "<br>") AS result FROM animals LEFT JOIN friends ON animals.id=friends.id');
更多细节和解释here