SELECT * FROM abc where xjzh like '%[^0-9a-zA-Z]%'
#5
可以问您一个问题吗?这里有9行记录,哪些记录要排除呢
INSERT INTO #test( ID, Val ) VALUES(1,N'啊啊啊001') INSERT INTO #test( ID, Val ) VALUES(2,N'棒棒棒ABC') INSERT INTO #test( ID, Val ) VALUES(3,N'123ABC') INSERT INTO #test( ID, Val ) VALUES(4,N'123axzQ') INSERT INTO #test( ID, Val ) VALUES(5,N'哦哦ab') INSERT INTO #test( ID, Val ) VALUES(6,N'11哦哦ab') INSERT INTO #test( ID, Val ) VALUES(7,N'1111') INSERT INTO #test( ID, Val ) VALUES(8,N'xyz') INSERT INTO #test( ID, Val ) VALUES(9,N'ABC')
另外,
SELECT * FROM abc where xjzh not like '%[a-z]%' or xjzh not like '%[0-9]%'
的等价逻辑是:
SELECT * FROM abc EXCEPT SELECT * FROM abc WHERE ( xjzh like '%[a-z]%') AND (xjzh like '%[0-9]%')
也就是先查出既包含[a-z|A-Z]和[0-9]的字串,然后对所有记录取补集
#1
SELECT * FROM abc where xjzh not like '%[a-z]%'
or xjzh not like '%[0-9]%'
#2
SELECT * FROM abc where xjzh not like '%[a-z]%'
or xjzh not like '%[0-9]%'
SELECT * FROM abc where xjzh like '%[^0-9a-zA-Z]%'
#5
SELECT * FROM abc where xjzh not like '%[a-z]%'
or xjzh not like '%[0-9]%'
因为是两个条件选其一,会把全部数字,全部字母的搜出来的。
可以问您一个问题吗?这里有9行记录,哪些记录要排除呢
INSERT INTO #test( ID, Val ) VALUES(1,N'啊啊啊001') INSERT INTO #test( ID, Val ) VALUES(2,N'棒棒棒ABC') INSERT INTO #test( ID, Val ) VALUES(3,N'123ABC') INSERT INTO #test( ID, Val ) VALUES(4,N'123axzQ') INSERT INTO #test( ID, Val ) VALUES(5,N'哦哦ab') INSERT INTO #test( ID, Val ) VALUES(6,N'11哦哦ab') INSERT INTO #test( ID, Val ) VALUES(7,N'1111') INSERT INTO #test( ID, Val ) VALUES(8,N'xyz') INSERT INTO #test( ID, Val ) VALUES(9,N'ABC')
另外,
SELECT * FROM abc where xjzh not like '%[a-z]%' or xjzh not like '%[0-9]%'
的等价逻辑是:
SELECT * FROM abc EXCEPT SELECT * FROM abc WHERE ( xjzh like '%[a-z]%') AND (xjzh like '%[0-9]%')