如何在SQLite中使用正则表达式 [英] How to use regexp in sqlite
本文介绍了如何在SQLite中使用正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请提示,如何在SQLite中使用REGEXP?
Please prompt, how used REGEXP in SQLite?
实现:
SELECT field FROM table WHERE field REGEXP '123'
它不起作用. Error: no such function: REGEXP
推荐答案
当前正在Ubuntu 12.04中为我的Web应用程序开发sqlite3 + php.经过研究后,我也遇到了同样的问题,我发现我们需要为sqlite3安装一个pcre软件包.这里我们要怎么做
Currently am working on sqlite3+php for my web application in Ubuntu 12.04. I was also faced the same issue then after research i had found that we need to install one pcre package for sqlite3. Here we go how to
-
apt-get install sqlite3-pcre
- 然后转到sqlite3命令行
sqlite3 test.db
- 运行命令
.load /usr/lib/sqlite3/pcre.so
- 测试:
SELECT url FROM table_name where url REGEXP '^google.*';
apt-get install sqlite3-pcre
- Then go to sqlite3 command line
sqlite3 test.db
- run the command
.load /usr/lib/sqlite3/pcre.so
- test :
SELECT url FROM table_name where url REGEXP '^google.*';
按照这三个步骤进行操作对我来说很好. 如果对此有误,请纠正我. 希望对您有帮助
After following those 3 steps its working fine for me. If am wrong regarding this please correct me. I hope it will help you
谢谢
这篇关于如何在SQLite中使用正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文