I want to get records that their titles contains "hello #12", so I used this query:
Post::query()->where('title', 'LIKE', "%hello #12%");
Problem is it returns some records with titles like this:
"hello #15", "hello you" and …
Is # have special use in mysql or laravel query?
How can I get the result I wanted?
2
Answers
I think what’s happening is that when you’re querying like that, you are actually escaping the character #. (Double Quotes)
So, instead try this way:
I tested your problem and got proper results by using the following query syntax (Model Facade):
Extra: if you dd() your query, im my case:
you´ll see, that the ‘#’ character is interpreted as inteded as part of the full query string.