我正在尝试在下面的查询中从列街获取带有特殊字符的记录:
select A.Street
from ADRC a
where A.Street LIKE '%[^A-Za-z0-9, ]%';
但它不会返回结果。我想选择包含特殊(非字母数字)字符的任何记录:
我刚用'*'检查过,你可以看到有很多特殊字符的数据。
答案 0 :(得分:-3)
你不需要%[^]
因为喜欢这样做
select A.Street
from ADRC a
where A.Street LIKE '[A-Za-z0-9, ]%';
WITH temp_table AS (
SELECT '*royal oak' Street from dual
UNION ALL
SELECT '459*' Street from dual
UNION ALL
SELECT '5TH* AVE' Street from dual
UNION ALL
SELECT ' 5TH* AVE' Street from dual
UNION ALL
SELECT ',5TH* AVE' Street from dual
)
select A.Street
from temp_table a
where REGEXP_LIKE(A.Street,'^[A-Za-z0-9, ]') ;
如何在所有5列中获取包含spcl字符的记录?
WITH temp_table AS (
SELECT '*royal oak' col1,'*royal oak' col2,'*royal oak' col3,'*royal oak' col4,'*royal oak' col5 from dual
UNION ALL
SELECT '5TH* AVE' col1,'5TH* AVE' col2,'5TH* AVE' col3,'5TH* AVE' col4,'5TH* AVE' col5 from dual
)
select *
from temp_table a
where REGEXP_LIKE(A.col1,'^[A-Za-z0-9, ]') or REGEXP_LIKE(A.col2,'^[A-Za-z0-9, ]')
or REGEXP_LIKE(A.col3,'^[A-Za-z0-9, ]') or REGEXP_LIKE(A.col4,'^[A-Za-z0-9, ]') or REGEXP_LIKE(A.col5,'^[A-Za-z0-9, ]');