Skip to content
Advertisement

LIKE statement SQL

Dont work brackets in LIKE statement

I use MySQL WorkBench, I dont understand why SELECT * from user where name like'B[io]' dont work.

My DataBase:

enter image description here

Advertisement

Answer

Because MySQL does not support character classes in like expressions. Neither does the SQL standard.

Use regular expressions:

where name regexp '^B[io]'

Incidentally, the like does work. You just have no data that starts with the five characters 'B', '[', 'i', 'o', and ‘]' in that order.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement