MySQL SELECT LIKE or REGEXP to match multiple words in one record(MySQL SELECT LIKE 或 REGEXP 匹配一条记录中的多个单词)
问题描述
字段table
.name
包含'Stylus Photo 2100' 和以下查询
The field table
.name
contains 'Stylus Photo 2100' and with the following query
SELECT `name` FROM `table` WHERE `name` LIKE '%Stylus 2100%'
我没有得到任何结果.当然,如果我搜索了
I get no results. Of course i would if i searched
SELECT `name` FROM `table` WHERE `name` LIKE '%Photo 2100%'
如何通过搜索Stylus 2100"来选择记录?
How can I select the record by searching 'Stylus 2100' ?
谢谢
推荐答案
好吧,如果您知道单词的顺序.. 您可以使用:
Well if you know the order of your words.. you can use:
SELECT `name` FROM `table` WHERE `name` REGEXP 'Stylus.+2100'
你也可以使用:
SELECT `name` FROM `table` WHERE `name` LIKE '%Stylus%' AND `name` LIKE '%2100%'
这篇关于MySQL SELECT LIKE 或 REGEXP 匹配一条记录中的多个单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:MySQL SELECT LIKE 或 REGEXP 匹配一条记录中的多个单词


- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- SQL 临时表问题 2022-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
- 更改自动增量起始编号? 2021-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01