我有下面这样一个专栏
**col1**1244a888dahahd我我是19mon
**col1**
1244
a888d
ahahd
我
我是
19mon
我想要的结果是
**col1**a888d我是19mon
我试着用下面的语法来排除数字和字母表,但是没有字符串被打印出来。我不知道怎么排除一个中文单词,比如“我" 上面。
SELECT col1 from abcwhere col1 like '%[^0-9.]%' AND col1 like '%[^a-zA-Z.]%'
SELECT col1 from abc
where col1 like '%[^0-9.]%' AND col1 like '%[^a-zA-Z.]%'
有什么办法解决这个问题吗?谢谢您!
xwmevbvl1#
使用正则表达式:
with your_data as (select stack(6,'1244','a888d','ahahd','我','我是','19mon') as col1) select col1 from your_data where col1 not rlike ('^\\d+$') --not digits only and col1 not rlike ('^[a-zA-Z]+$') --not alpha only and length(col1) !=1; --not single char (digit and alpha filtered already)
with your_data as (
select stack(6,
'1244',
'a888d',
'ahahd',
'我',
'我是',
'19mon'
) as col1
)
select col1 from your_data
where col1 not rlike ('^\\d+$') --not digits only
and col1 not rlike ('^[a-zA-Z]+$') --not alpha only
and length(col1) !=1; --not single char (digit and alpha filtered already)
退货:
col1 a888d 我是 19mon
col1
演示:http://demo.gethue.com/hue/editor?editor=324999
tvmytwxo2#
你可以尝试以下方法:
SELECT *FROM abcWHERE LOWER(col1) != UPPER(col1) -- COLLATE Latin1_General_CS_AS SQL Server specific OR (LENGTH(col1) != 1 AND col1 like '%[^a-zA-Z.0-9]%');
SELECT *
FROM abc
WHERE LOWER(col1) != UPPER(col1) -- COLLATE Latin1_General_CS_AS SQL Server specific
OR (LENGTH(col1) != 1 AND col1 like '%[^a-zA-Z.0-9]%');
db<>小提琴演示
2条答案
按热度按时间xwmevbvl1#
使用正则表达式:
退货:
演示:http://demo.gethue.com/hue/editor?editor=324999
tvmytwxo2#
你可以尝试以下方法:
db<>小提琴演示