如何在SQLite中使用正则表达式 [英] How to use regexp in sqlite

查看:1876
本文介绍了如何在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

  1. apt-get install sqlite3-pcre
  2. 然后转到sqlite3命令行sqlite3 test.db
  3. 运行命令.load /usr/lib/sqlite3/pcre.so
  4. 测试:SELECT url FROM table_name where url REGEXP '^google.*';
  1. apt-get install sqlite3-pcre
  2. Then go to sqlite3 command line sqlite3 test.db
  3. run the command .load /usr/lib/sqlite3/pcre.so
  4. 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屋!

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