当一个字段以逗号隔开存多个id,用sql语句取这个id对应表中的名称
作者:互联网
SELECT p.id, p.apply_area_ids, GROUP_CONCAT(area.`name`) as apply_area_names FROM ap_product p LEFT JOIN ap_product_company pc on pc.id = p.product_company_id LEFT JOIN ap_area area on FIND_IN_SET(area.id,p.apply_area_ids) WHERE p.user_id = 1 and pc.is_del = 0 GROUP BY p.id
标签:product,area,表中,pc,ap,sql,apply,id 来源: https://www.cnblogs.com/huang2979127746/p/16381944.html