Invalid Mysql characters error?

Asked

Viewed 41 times

1

I am using this query to do a database search:

SELECT * FROM cidades WHERE cidade LIKE ? LIMIT 1

in the placeholder I used "Narnia"

And I got this mistake:

General error: 1267 Illegal mix of collations (utf8_bin,IMPLICIT) and (utf8mb4_general_ci,COERCIBLE) for operation 'like' trace

How to solve this?

1 answer

1

The operator LIKE needs other information - called wildcards - in his placeholder to understand what to do, such as %.

So try something like this:

SELECT * FROM cidades WHERE cidade LIKE '%Nárnia%' LIMIT 1

I don’t know what technology you’re using to replace the placeholder then it must be something like this:

SELECT * FROM cidades WHERE cidade LIKE '%?%' LIMIT 1

Comment here on the right way to do it, and tell me the technology you are using, please.

  • I will, test, I am using PHP, with the Redbean ORM, thanks for the reply.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.