[英]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. 我有一个字符串
"abc"
,我想在SQL表中搜索包含a,b或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 有关更多检查信息, 请参见http://www.techonthenet.com/sql/like.php
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.