Group values by a common value: userid and ipaddress

前端 未结 3 2062
说谎
说谎 2021-01-27 16:06

I\'m working on a problem in my database. I\'m trying to find the users who are using multiple accounts. I have a list of user IDs and used IP addresses, like this:

Us

3条回答
  •  心在旅途
    2021-01-27 16:22

    Use GROUP_CONCAT()

    SELECT user_id, GROUP_CONCAT(DISTINCT ip_address SEPARATOR ', ') 
    FROM TABLE_NAME GROUP BY user_id
    

提交回复
热议问题