首页 > 解决方案 > 如何在 db2 查询中从字符串中获取特定值

问题描述

我的表具有这样的值“lowValue=100,upperValue=200”。

我尝试使用 substr 和 trim 函数来修剪 lowValue= 和 upperValue= 文本。没有什么对我有用

Select contantName,constantValue from Test where contantName="test1"; 

-------------------------------------------------
 contantName         constantValue
-------------------------------------------------
 test1               lowValue=100,upperValue=200
-------------------------------------------------

如何在选择查询中仅获取低值和高值。

我希望输出仅从常量值 100 和 200 中获取数字。

标签: sqldb2db2-luw

解决方案


select contantName, REPLACE(REPLACE(constantValue,'lowValue=',''), 'upperValue=','') from Test where contantName="test1";


推荐阅读