sql - Why does my query with LIKE '%\_' return all rows and not just those ending in an underscore? -
I am currently running a query on PostGrace:
SELECT * from addenda.users WHERE user Like the username '% \ _'
But instead of returning entries that end in one entry, I get all the results back, even if there is an underscore in it.
Returns a username given below, which only gives an underscore, so the escape is done:
SELECT * from addenda.users where user. Like the username \ '"
and gives the following query to a user name that ends with a special letter (s):
< Addenda.users from the code> SELECT * where the user What am I doing wrong?
Is not your backslash available with PostGraceSQL? If you are passing strings through another layer which treats backslash as escape characters (like Java string), then that layer can remove backslash, and you can avoid your backslash for that layer May be required.
Do you have any single character username? If the backslash is not reaching PostGraceSQL, they will match '_'
You might try this: Username '%! _ 'Escape'! '
Comments
Post a Comment