简体   繁体   English

SQL搜索包含字符的字符串

[英]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.

相关问题 SQL Server全文搜索以查找包含字符 - SQL Server Full Text Search to find containing characters SQL搜索包含的术语 - SQL search for containing terms SQL Where..Like子句,用于包含空格和特殊字符(如@,!,#)的搜索条件 - SQL Where..Like clause for search criteria containing a Space and special characters like @, !, # 搜索字符串中的字符并将其替换为空格T-SQL - Search characters in a String and replace it with a blank space T-SQL 使用SQL是否可以通过字符串搜索而无需考虑字符的顺序? - Using SQL is it possible to search via string without regards to the order of the characters? SQL通过包含字符串排序 - SQL sort by containing string 搜索模式并删除搜索字符串字符(如果找不到),然后在oracle sql中再次搜索 - Search pattern and remove search string characters if not found and then search it again in oracle sql 包含变音符号的字段的sql搜索 - sql search on fields containing diacritics 如何在包含来自SQL中另一个单元格的字符串的单元格子字符串中搜索字符串 - How do I search for a string in a cell substring containing a string from another cell in SQL SQL 选择仅包含特殊字符的值 - SQL select values containing only special characters
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM