String 使用Postgres操作字符串

String 使用Postgres操作字符串,string,postgresql,String,Postgresql,我需要从事件表中提取产品和产品版本,即emas产品和版本3.2.5 这是一个如下所示的事件表: 带着疑问 select creacion,descripcion from event where descripcion ~ 'Paso de desarrollo a test'; 我有以下结果: 但我希望得到如下结果: product=emas version=3.2.5 我尝试了一些查询,如: select creacion,descripcion from evento whe

我需要从事件表中提取产品和产品版本,即emas产品和版本3.2.5

这是一个如下所示的事件表:

带着疑问

select creacion,descripcion 
from event 
where descripcion ~ 'Paso de desarrollo a test';
我有以下结果:

但我希望得到如下结果:

product=emas version=3.2.5
我尝试了一些查询,如:

select creacion,descripcion 
from evento 
where descripcion ~ 'Paso de desarrollo a test emas R' select substring ('Paso de desarrollo a test emas R',26);

select creacion,descripcion 
from evento 
where descripcion ~ substring ('Paso de desarrollo a test emas R',26);

select substring('Paso de desarrollo a test') as producto select substring('R-' ) as versión, creacion,descripcion  where descripción like 'Paso de desarrollo a test%';
但是我没有得到我需要的东西


我应该如何进行此查询并处理结果?

您的问题不是很清楚,但您似乎希望从
说明中提取版本和产品,并以列格式表示。
试试这个:

select 
split_part(split_part(descripcion,'Development step to test ',2),' ',1) "product",
substring(descripcion from '\d+.\d+.\d+') "version"
from event where descripcion ~ 'Development step to test ';

这是我用来解决这个问题的查询。我希望能帮助别人

选择上部(子串(子串(描述离子,27),0,长度(子串(描述离子,27))-位置(''反向(子串(描述离子,27)))+1))作为“产品”,替换(替换(替换(反向(子串(反向(描述离子),0,位置(''反向(描述离子))),'R-','','R','','R',''作为“版本”,creacion
来自evento,其中描述了“Paso de desarrollo a测试”

我需要从这个结果中提取产品和版本,在本例中是“emas”和“3.2.5”。并将其格式设置为“product=emas version=3.0.5”?为什么这是错误的?我尝试的前两个查询没有改变最终结果,输出仍然与图片相同。第二个给出了错误SQL error[42601]:错误:error de sintaxis en o cerca de«select»位置:49@AkhileshMishra姓氏始终是产品,最后3个数字(在R之后)是版本,但在您的示例中,R并不总是存在,有时它会丢失或
R-
或“R.”。甚至有时产品和版本之间也没有空间。