使用split_part(string text, delimiter text2, field int)
以字符为标识截取
其中:
- text 为截取字段
- text2 为截取标识符:按照什么形式切割(比如逗号’,’)
- int 为删除项目的位置:位置从1开始
举例:查询一个满足条件的灾害点图片
select image from geohazard_all_english where x = '110.31417' and y = '30.63582' and type = '地面沉降' and date = '201912'
由图可知,查询结果有多个,且通过,
分割,因此使用split_part
select split_part(image,',',1) as image from geohazard_all_english where x = '110.31417' and y = '30.63582' and type = '地面沉降' and date = '201912'
查询结果就保留了一条