我有两个表,我需要从中选择数据
用户
id email
----------
1 email1
2 email2
设置
usrid name value
--------------------
1 set1 value1
1 set2 value2
2 set1 value1
2 set2 value2
我使用的sql是
SELECT u.email, s . *
FROM `sers` u
INNER JOIN `settings` s ON u.id = s.usrid
LIMIT 0 , 30
但我明白了
email name value
------------------
email1 set1 value1
email1 set1 value1
email2 set2 value2
email2 set2 value1
有什么办法可以得到
email1 set1 value1 set1 value1 etc
email2 set2 value2 set2 value2 etc
从 group_concat 我试过这个
SELECT u.email, GROUP_CONCAT(s.name,s.value) as vals FROM `users` u INNER JOIN `settings` s ON u.id = s.usrid GROUP BY u.email
这给了
email1 set1value1,set1value1 etc
我怎样才能在逗号之间的每个值之间放置一个分隔符
喜欢
email1 set1=value1,set1=value1 etc