200字范文,内容丰富有趣,生活中的好帮手!
200字范文 > SQL:pgSQL截取查询结果

SQL:pgSQL截取查询结果

时间:2022-07-01 08:03:08

相关推荐

SQL:pgSQL截取查询结果

使用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 = '12'

由图可知,查询结果有多个,且通过,分割,因此使用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 = '12'

查询结果就保留了一条

使用substr(text,int 4,int 4)可以截取特定位置之间的字符

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。