sql - 如何在 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 中获取数字。
解决方案
select contantName, REPLACE(REPLACE(constantValue,'lowValue=',''), 'upperValue=','') from Test where contantName="test1";
推荐阅读
- python - scikit-learn 中的部分交叉验证
- c - HTTP 错误:C 中套接字编程中的错误请求
- python - 当我在 Pika 创建永久发布者时遇到问题
- node.js - 如何处理 Puppeteer “错误:页面崩溃!”
- c# - 如何通过 C# 连接 Phoenix
- javascript - 将相同的键值聚合到一个数组中并避免未定义
- c - 自定义 Malloc() 函数 :: 这个语法是什么意思?
- java - Spark数据集合并多行
- java - Spring CrudRepository:未附加编程配置的实体,附加 DataJpaTest
- python - ValueError:维度必须为 4,但对于输入形状为 [?,10,16,16], [3] 的“capsule_2/transpose_4”(操作:“Transpose”)为 3