MySQL在表字段中的确切单词是否存在检查 [英] MySQL exact word existence check in a table Field

查看:118
本文介绍了MySQL在表字段中的确切单词是否存在检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个查询.是否有任何与MySQL相关的内置函数或任何其他方法,这些函数将返回数据库表字段中包含EXACT字的行?我知道,使用MySQL LIKE运算符,您可以在将字符串值与包含通配符的模式字符串匹配的列中搜索指定的模式.但是使用MySQL LIKE子句,它也将返回子字符串条目.

I've a Query. Is there any built-in function or any other method associated with MySQL, which will return rows that contains EXACT word in the database table field? I'm aware that with MySQL LIKE operator, You can search for a specified pattern in a column which will match a string value against a pattern string containing wild-card characters. But With MySQL LIKE clause, It'll return substring entries too.

例如.

假设3个列值如下:

1. "Take another shot of courage"

2. "The End of This age is Not Yet"

3. "Employers can obtain this wage rate by submitting a request"

我想检索所有列值包含确切单词'age'的行

I want to retrieve all rows in which column value contains the exact word 'age'

如果我们准备这样的查询

If we prepare query like this

SELECT * FROM sometable WHERE somefield LIKE '%age%'

它将返回所有三行.但是我的意图只是获得第二排.我们如何实现这一目标?提前谢谢.

It'll return all three rows. But my intention is only to get the second row. How do we achieve this? Thanks In Advance.

干杯,
JENSon.

推荐答案

使用此查询

SELECT * FROM sometable WHERE somefield LIKE '% age %' 
OR somefield LIKE 'age %' OR somefield LIKE '% age'

这篇关于MySQL在表字段中的确切单词是否存在检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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