fumingxia 发表于 2016-10-24 10:07:57

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
页: [1]
查看完整版本: mysql的group_concat方法和正则(REGEXP)的结合使用