关于一个模糊搜索的问题

来源:百度知道 编辑:UC知道 时间:2024/05/29 02:44:47
有一下数据库字段内容:
表名 cp
内容字段(content)
cement opc42.5 clinker rizhao
cement opc42.5 clinker rizhao
cement opc42.5 clinker
cement opc42.5 clinker f
mycement opc42.5 clinker rizhao
cement opc42.5 myclinker rizhao
cement opc42.5 clinkermy rizhao

我现在搜索cement clinker这个关键词,上面的前4条信息必须搜出来,
后3条不能搜索出来,请问这样的语句怎么写?
SQL 搜索语句

%cement%clinker%

我看你楼主提供的数据格式,写了一段SQL,你看看,
select 'cement opc42.5 clinker rizhao' texts into #mm
union all
select 'cement opc42.5 clinker rizhao '
union all
select 'cement opc42.5 clinker '
union all
select 'cement opc42.5 clinker f '
union all
select 'mycement opc42.5 clinker rizhao'
union all
select 'cement opc42.5 myclinker rizhao'
union all
select 'cement opc42.5 clinkermy rizhao '

select * from #mm where substring(texts,16,8)='clinker' and texts like 'cement%'

select * from cp
where content like '%cement%'
and content like '%clinker%'

select * from cp
where content like 'cement opc42.5 clinker %'

C 语言。。还是程序表