0

I'd like to query all user_questions where a question ends with a '\'.

I tried the following but the none of them seem to work. All of them return empty results.

select * from user_question where question like "%\\"

select * from user_questions where question like "%[\]"

select * from user_questions where question like "%\\\\"

select * from user_questions where question like "%[\\]"

I am using mysql workbench 6.0.7

mysql - How to handle query search with special characters /(forward slash) and \(backslash)

Community
  • 1
  • 1
Karan Verma
  • 1,721
  • 1
  • 15
  • 24

2 Answers2

0
select * from user_questions where question like "%\\\\"

This one should work, tested it myself.

user2103237
  • 69
  • 1
  • 8
  • It gives a syntax error: Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"%\\\"' at line 1 – Karan Verma Dec 20 '13 at 21:59
  • Wow, indeed 4 to be exact.. I edited multiple times because it wasn't how I wanted it.. and now it all changed weird. Caused by ctrlk+k on last edit, sorry boys :) – user2103237 Dec 20 '13 at 22:00
0

Did you try this?

select *
from user_question
where right(question, 1) = '\\';
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786