有一个表,其中包含代理字段。这是字符串
神父。7.2.5 (950) / iPhone (iOS 155) / x86_64
神父。7.25.5 (950) / iPhone (iOS 155) / x86_64
神父。7.225.5 (950) / iPhone (iOS 155) / x86_64
这是请求
select * from some_table where agent ilike '%7.2%ios%
为了不仅找到必要的数字,而且找到某些单词(有必要选择包含“ios”的行),我必须这样做(带有 cte ... 的表达式由@Akina 提供)
CREATE TEMPORARY TABLE temp1 AS
SELECT *
FROM some_table rt
WHERE rt.agent ilike '%ios%';
select * from temp1;
WITH cte AS (
SELECT agent, regexp_split_to_array(agent, '\D+') parts
FROM temp1
)
SELECT *
FROM cte
WHERE parts[2] :: INT < 7
OR parts[3] :: INT < 105;
更新(一查询解决方案)
WITH cte AS (
SELECT agent, regexp_split_to_array(agent, '\D+') parts
FROM reactive_table
)
SELECT *
FROM cte
WHERE cte.agent ilike '%ios%'
and (parts[2] :: INT < 8
OR parts[3] :: INT < 105
);
如何查找版本低于7.104的所有行?
小提琴