sql函数

1.替换,拼接
    REPLACE ( group_concat( DISTINCT ROUND( c.area) ORDER BY
    c.area ), ',', '/' )
2.FIND_IN_SET查询
SELECT   
a.*,
REPLACE (
  group_concat(b.policy_name),
  ',',
  '、'
 ) AS buildingNames FROM ff_server_activity_manage a, ff_server_preferential_policy b WHERE FIND_IN_SET(b.id, a.policy_ids) GROUP BY a.id
3.拼接字符串
CONCAT('#',fsbi.building_name ,'-',fshm.unit_no,'-' ,fshm.room_number) AS "housingResource",
4.MySql逗号拼接字符串查询的两种方法
下面两个函数的使用和FIND_IN_SET一样,使用时只需要把FIND_IN_SET换成FIND_PART_IN_SET或FIND_ALL_PART_IN_SET
例如某字段里是为1,2,3,4,5
使用方法:
第一种,传入1,3,6  可以查出来
select * from XXX where FIND_PART_IN_SET('1,3,6','1,2,3,4,5')
第二种,传入1,3,6  查不出来
select * from XXX where FIND_ALL_PART_IN_SET('1,3,6','1,2,3,4,5')

 

你可能感兴趣的:(sql函数)