oracle中:
------------
SQL> create table test(a varchar2(10));
Table created.
SQL> insert into test values('鸟');
1 row created.
SQL> commit;
Commit complete.
SQL> insert into test values('深刻');
1 row created.
SQL> commit;
Commit complete.
SQL> insert into test values('aaa');
1 row created.
SQL> insert into test values('bbb');
1 row created.
SQL> commit;
Commit complete.
SQL> select a from test;
A
----------
鸟
深刻
aaa
bbb
SQL> select a from test where asciistr(a) like '%\%';
A
----------
鸟
深刻
SQL> select a from test where asciistr(a) not like '%\%';
A
----------
aaa
bbb
Table created.
SQL> insert into test values('鸟');
1 row created.
SQL> commit;
Commit complete.
SQL> insert into test values('深刻');
1 row created.
SQL> commit;
Commit complete.
SQL> insert into test values('aaa');
1 row created.
SQL> insert into test values('bbb');
1 row created.
SQL> commit;
Commit complete.
SQL> select a from test;
A
----------
鸟
深刻
aaa
bbb
SQL> select a from test where asciistr(a) like '%\%';
A
----------
鸟
深刻
SQL> select a from test where asciistr(a) not like '%\%';
A
----------
aaa
bbb
select a,asciistr(a) from test where asciistr(a) like '%\%';
A ASCIISTR(A)
---------- --------------------------------------------------
鸟 \FFFD\FFFD
深刻 \FFFD\FFFD\FFFD\FFFD
A ASCIISTR(A)
---------- --------------------------------------------------
鸟 \FFFD\FFFD
深刻 \FFFD\FFFD\FFFD\FFFD
----------------------------------------------------------------------------------------------------------------------
sql中:
--------
declare @t table([Name] nvarchar(10))
insert @t select '好的啊!'
insert @t select '12345好的'
insert @t select '123'
insert @t select 'sdff'
select * from @t where PATINDEX('%[吖-座]%',[name])>0
/*
Name
----------
好的啊!
12345好的
(所影响的行数为 2 行)*/
insert @t select '好的啊!'
insert @t select '12345好的'
insert @t select '123'
insert @t select 'sdff'
select * from @t where PATINDEX('%[吖-座]%',[name])>0
/*
Name
----------
好的啊!
12345好的
(所影响的行数为 2 行)*/
------------------------------------------------------------
PATINDEX('%[吖-座]%',[name])>0