如何在MySQL选择查询中编写正则表达式? [英] how to write Regular Expression in MySQL select queries?

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

问题描述

我尝试使用此表达式/\b(word\w*)\b/iword与其他单词的列表进行比较,以找到重复项.我使用了preg_math_all(),它工作正常.我想做同样的事情,但是这次对照从mysql数据库中检索到的单词进行检查.这就是我写的

I tried this expression /\b(word\w*)\b/i to compare a word against the list of other words to find the duplicates. I used preg_math_all() and it worked fine. I wanted to do the same thing but this time check against the words retrieved from mysql database. This is what i wrote

SELECT * FROM table WHERE word = /\b(word\w*)\b/i

这没用.

推荐答案

您的查询应类似于:

SELECT * FROM table WHERE column REGEXP '/\b(word\w*)\b/i'

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

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