+ -
当前位置:首页 → 问答吧 → vb sql 怎么模糊查询到ou但不包括our的数据。

vb sql 怎么模糊查询到ou但不包括our的数据。

时间:2011-07-24

来源:互联网

vb sql 怎么模糊查询到ou但不包括our的数据。

希望查询到的是包含ou,但不希望出现our(里面也包含ou)

作者: xnt   发布时间: 2011-07-24

先查询到包含ou的,再剔除包含our的

作者: yiguangqiang88   发布时间: 2011-07-24

引用楼主 xnt 的回复:
vb sql 怎么模糊查询到ou但不包括our的数据。

希望查询到的是包含ou,但不希望出现our(里面也包含ou)
SQL code
select * from table_name where xxx like '%ou'

作者: Alice814108771   发布时间: 2011-07-24

SQL code
select * from 表名 where 字段名 like 'ou[^r]%'

作者: Leftie   发布时间: 2011-07-24

不好意思不小心看错;额

作者: Alice814108771   发布时间: 2011-07-24

引用 3 楼 leftie 的回复:
SQL code
select * from 表名 where 字段名 like 'ou[^r]%'
这个查询下来只有OUSQL code
select * from lcc where name  not like 'our' and name like '%ou%'
这样可以

作者: Alice814108771   发布时间: 2011-07-24

SQL code

create table lcc
(
id int identity(1,1) primary key,
name varchar(20) not null 
)
insert into lcc values('our')
insert into lcc values('ou')
insert into lcc values('cou')
insert into lcc values('cour')
insert into lcc values('ourm')
insert into lcc values('xxx')
select * from lcc
select * from lcc where name  not like 'our' and name like '%ou%'

作者: Alice814108771   发布时间: 2011-07-24