select 字段1,字段2,....字段n from table where 字段n like '%[^1-9]1Q%'
select * from 表 where 字段 like '%[^1-9]1Q%'
[^1-9] 有点象UNIX的正则表达式 :)
select 字段名 from 表 where 字段 like '%[^1-9]1Q%'
谢谢楼上各位大侠的答复! 但好像不行啊。我是这样试验的: create table test (name nvarchar(100), addr nvarchar(100), id int)insert into test values('1q','ww',5) insert into test values('11q','ww2',5) insert into test values('21q','ww3',5) insert into test values('31q','ww4',5) insert into test values('41q','ww5',5) 当我执行select * from test where name like '%^[1-9]1q%'时,没有数据出来啊 请教请教!
select * from test where name not like N'%[1-9]1q%'
谢谢楼上大侠的答复! 但是要是我嫁了一条insert into test values('qqq','ww5',5)那么select * from test where name not like N'%[1-9]1q%' 就会把('1q','ww',5)和('qqq','ww5',5)两条记录都查询出来了。当我只要('1q','ww',5)就是有1q,但是又不是11q,21q,31q,怎么办?
但好像不行啊。我是这样试验的:
create table test
(name nvarchar(100),
addr nvarchar(100),
id int)insert into test values('1q','ww',5)
insert into test values('11q','ww2',5)
insert into test values('21q','ww3',5)
insert into test values('31q','ww4',5)
insert into test values('41q','ww5',5)
当我执行select * from test where name like '%^[1-9]1q%'时,没有数据出来啊
请教请教!
但是要是我嫁了一条insert into test values('qqq','ww5',5)那么select * from test where name not like N'%[1-9]1q%'
就会把('1q','ww',5)和('qqq','ww5',5)两条记录都查询出来了。当我只要('1q','ww',5)就是有1q,但是又不是11q,21q,31q,怎么办?