Russell Dias
Russell Dias

Reputation: 73402

MySQL Wildcards * and %

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

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

Upvotes: 27

Views: 63605

Answers (2)

Lance
Lance

Reputation: 5800

"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.

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

I hope that helps.

Upvotes: 6

Björn
Björn

Reputation: 29401

* 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.

Upvotes: 48

Related Questions