mysql的group_concat方法和正则(REGEXP)的结合使用
select (select group_concat(a.name) from addressbook a where a.mobile in (s.receive_mobiles)) names,s.receive_mobiles from sms_send_record s where id=77;
+——-+————————————-+
| names | receive_mobiles |
+——-+————————————-+
| NULL | 13825722737,13375006095,13875005239 |
+——-+————————————-+
1 row in set
select (select group_concat(a.name) from addressbook a where a.mobile REGEXP replace(s.receive_mobiles,',','|')) names,s.receive_mobiles from sms_send_record s where id=77;
+———————-+————————————-+
| names | receive_mobiles |
+———————-+————————————-+
| 张款民,宋里露,王 华 | 13825722737,13375006095,13875005239 |
+———————-+————————————-+
1 row in set