Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

use of wild card for set of first letters notworking mysql

This is the query I’m using but it’s returning an empty table

select ename from new_schema.employee where ename like '[svg]%' ;

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

It looks like you’re using Microsoft SQL Server syntax for the pattern.

MySQL only supports standard wildcards for the LIKE predicate. I.e. % and _, but not square brackets.

You can use a regular expression instead of LIKE to search for a character class:

select ename from new_schema.employee where ename REGEXP '^[svg].*' ;

You should keep in mind that every vendor of SQL database does things differently, and implements their own ideas about extensions to standard SQL. You need to refer to documentation for the brand and version you are using, and don’t expect features that work in one brand (Microsoft) to work the same in another brand (MySQL).

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading