更新时间:2023-10-23 15:46:58
它确实很奇怪,因为存在某些行的叉积.您可以使用DISTINCT
关键字仅获取唯一的电话号码:
It does weird things, becaue there is a cross product of certain rows. You can use the DISTINCT
keyword to get only unique phone numbers:
GROUP_CONCAT(DISTINCT phones.phone_number) AS phone_numbers,
检查文档.或者,您可以在另一个查询中获取电话号码,在该查询中,您仅选择条件为WHERE phones.user_id IN (x, x, x, ...)
(x是从第一个查询返回的ID)的电话号码.
Check the documentation. Alternatively, you can get the phone numbers in another query where you would select only the phone numbers with a condition like WHERE phones.user_id IN (x, x, x, ...)
(x are IDs returned from the first query).