MySQL 通配符 * 和 %

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3070411/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 16:22:28  来源:igfitidea点击:

MySQL Wildcards * and %

sqlmysql

提问by Russell Dias

What is the difference between %and *wildcards in MySQL?

MySQL中的通配符%*通配符有什么区别?

In a query like so : "SELECT * FROM $table WHERE MATCH (message) AGAINST('$string*' IN BOOLEAN MODE)"

在这样的查询中: "SELECT * FROM $table WHERE MATCH (message) AGAINST('$string*' IN BOOLEAN MODE)"

回答by Bj?rn

*can only be used as a wildcard (or truncation) in a full text search while %(match 0 or more characters) and _(match exactly one character) are only applicable in LIKE-queries.

*只能在全文搜索中用作通配符(或截断),而%(匹配 0 个或多个字符)和_(恰好匹配一个字符)仅适用于 LIKE 查询。

回答by Lance

"An asterisk is the truncation operator. Unlike the other operators, it is appended to the word, or fragment, not prepended."

“星号是截断运算符。与其他运算符不同,它附加到单词或片段后,而不是前置。”

This only applies to MATCH() ... AGAINST()statements.

这仅适用于MATCH() ... AGAINST()语句。

The %is a LIKEwildcard and has nothing to do with the MATCH() ... AGAINST().

%是一个LIKE通配符和无关用MATCH() ... AGAINST()

I hope that helps.

我希望这有帮助。