【发布时间】:2015-06-30 05:50:25
【问题描述】:
我有一个表,其中有一列包含这些值
patern_number
0936
09154
123456
我有一个可以是任何数字的数字。
我想要的是一个选择,当输入数字以模式之一开始时返回 1,否则返回 0
例子
input number result
093628987 1
0915 0
0222 0
091546666 1
那么谁能帮帮我?
【问题讨论】:
-
select ... where value like '0936%' or value like '09154%' .....等等
-
嗨,安德烈,感谢您的回复,但我的图案编号太多了,我无法每个都喜欢
-
我知道这不是一个好方法,但你可以尝试这样(选择 col2 作为 'input_number','1' 作为 'result' FROM test.new_table where col2 LIKE '11%')联合(选择 col2 作为 'input_number','0' 作为 'result' FROM test.new_table where col2 not LIKE '11%');
-
嗨 caslaner,您能详细解释一下您的查询吗
-
你说的大概有多少种模式?有时它在技术上是可行的,但在性能方面无法发挥作用......
标签: sql sqlite pattern-matching