如何在 SQLite 查询中使用正则表达式? [英] How do I use regex in a SQLite query?

查看:335
本文介绍了如何在 SQLite 查询中使用正则表达式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 sqlite 中使用正则表达式,但我不知道如何使用.

I'd like to use a regular expression in sqlite, but I don't know how.

我的表有一列这样的字符串:3,12,13,14,19,28,32"现在,如果我输入where x LIKE '3'",我也会得到包含 13 或 32 等值的行,但我只想获取该字符串中值正好为 3 的行.

My table has got a column with strings like this: "3,12,13,14,19,28,32" Now if I type "where x LIKE '3'" I also get the rows which contain values like 13 or 32, but I'd like to get only the rows which have exactly the value 3 in that string.

有人知道如何解决这个问题吗?

Does anyone know how to solve this?

推荐答案

SQLite3 支持 REGEXP 运算符:

SQLite3 supports the REGEXP operator:

WHERE x REGEXP <regex>

http://www.sqlite.org/lang_expr.html#regexp

这篇关于如何在 SQLite 查询中使用正则表达式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆