Jump to content

How to identify _ as a character, not a wildcard


Recommended Posts

Hello! I have a database where values might be things like:

  • Apple
  • A_bumblebee
  • A_chair
  • Aster

With underscores as part of the name. I want to pull only the things that start with "A_", but my query thinks the _ is a wildcard. How do I tell it that I actually want that specific character?


Thank you in advance!


Link to comment
Share on other sites

From the MySQL reference manual ( https://dev.mysql.com/doc/refman/8.0/en/string-comparison-functions.html#operator_like )


 To test for literal instances of a wildcard character, precede it by the escape character. If you do not specify the ESCAPE character, \ is assumed.

    \% matches one % character.

    \_ matches one _ character.


Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...