There is a table called Students . I want to extract the names of students whose name begins with "n" or "p" or "y". I know that in TSQL (MS SQL server) I can write a query as follows and it works:
SELECT * FROM Students WHERE StudentName LIKE '[npy]%'
But when I execute the same query in MySQL (phpmyadmin), I was not able to get the correct result set. I tried to convert the letters of the student name to the same case that is mentioned in charlist. I did a little work on search engines and found out that in MySQL we need to specify this as a regular expression. I fulfilled the request below and got the expected result.
SELECT * FROM Students WHERE StudentName REGEXP '[[:<:]]n | [[:<:]]p | [[:<:]]y'
I want to know why the LIKE '[charlist]%' syntax LIKE '[charlist]%' does not work with MySQL. Is this due to the implementation in MySQL (MySQL does not support syntax) or is there something wrong with the version of phpmyadmin that I use?
Any help in this regard is much appreciated. Thanks:)
source share