简体   繁体   中英

SQL search for string containing characters

I have a string "abc" , and I want to search, in a SQL table, for the values that contain either a, b or c.

This is what I have right now:

Select * from TABLE where NAME like "abc" ;

This didn't work, but I know if I try something like

where Name like "a" or Name like "b" or ....

it will work.

Is there an easier way to do this? Since I don't want to separate my string into characters.

从ab中选择*,名称为REGEXP'[abc]'

You can use regular expression for this.
Have a look at the following :

Select * from TABLE where NAME REGEXP "[abc]";

This will do

Select * from TABLE where NAME like "%abc%" ;

For more check information here http://www.techonthenet.com/sql/like.php

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM