<p>Turns out asterisks can be escaped with a double slash, so you can query</p>
<pre><code>craft.entries.title('Foo\\*').all()
</code></pre>
<p>and it will match <code>Foo*</code></p>

CC BY-SA 4.0
2023-11-24T09:20:21.607Z
2023-11-24T09:20:21.607Z
gioppe
<p>I've noticed that the * wildcard works for simple custom field queries, for example if I have three entries named <code>Foo</code>, <code>Foo*</code>, <code>Foo*Bar</code>, running</p>
<p><code>craft.entries.title('Foo*').all()</code></p>
<p>will get 3 results, and if I dump the raw SQL there's a LIKE% statement. Is there a way to disable this behavior and query for an exact match? I could filter the results  with <code>firstWhere()</code> or similar, but it seems like an unexpected behavior.</p>

<search><query>
Wildcard searching for custom field queries
# Wildcard searching for custom field queries

(Asked by: username_0 on 2023-11-22)

I've noticed that the \* wildcard works for simple custom field queries, for example if I have three entries named `Foo`, `Foo*`, `Foo*Bar`, running

`craft.entries.title('Foo*').all()`

will get 3 results, and if I dump the raw SQL there's a LIKE% statement. Is there a way to disable this behavior and query for an exact match? I could filter the results with `firstWhere()` or similar, but it seems like an unexpected behavior.

**Tags:** search, query


---

## 1 answers

### Answer by username_0 on 2023-11-24. Score: 1 | Accepted answer

Turns out asterisks can be escaped with a double slash, so you can query
craft.entries.title('Foo\\*').all()

and it will match Foo*


---

