本文介绍了我的搜索没有找到结果!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

亲爱的,我已经将代码和示例输出数据说明了我的请求

在帖子中。我只是期待我的搜索amd

socket 32​​ bit cache 512 dell的一些结果。其中包括该搜索中所有

单词的逻辑AND。

因为我假设任何单词可能是item_name,item_key或

item_value,我将所有内容都包含在搜索中。


任何人都可以告诉我为什么我得到0结果?


我的数据的示例输出应该是这样的:


item_id item_name item_key item_value

--------------------- -----------------------------

1 Gefore MX 440尺寸64 MB

1 Gefore MX 440架构64位

1 Gefore MX 440 AGP 8x

1 Gefore MX 440芯片组Nvidia

1 Gefore MX 440供应商华硕

2 AMD 3200+级插座A

2 AMD 3200+速度2 GHz

2 AMD 3200+架构32位

2 AMD 3200+ 2级缓存512 KB

2 AMD 3200+供应商AMD

3戴尔P780几何17英寸

3戴尔P780屏幕类型平板

3戴尔P780频率60赫兹

3戴尔P780供应商D这是我的场景:


创建表item_table(item_id int identity(1,1)not null primary

key,item_name varchar(50)not null)

go

create table details_table(item_id int not null,item_key varchar

( 50),item_value varchar(50))

go

alter table details_table add foreign key(item_id)references

item_table

go


插入item_table值(''Gefore MX 440'')

go

插入item_table值(''AMD 3200+'')

go

插入item_table值(''戴尔P780'')

go


插入details_table值(1,''大小'','64 MB'')

go

插入details_table值(1,''架构'',''64位'')

go

插入details_table值(1,''AGP'',''8x' ')

go

插入details_table值(1,''Chipset'',''Nvidia'')

go

insert into details_table values(1,''Vendor'', ''华硕'')

go


插入details_table值(2,''Class'',''Socket A'')

go

插入details_table值(2,''速度'',''2 GHz'')

go

插入details_table值(2,''Architecture'',''32位'')

go

insert into details_table values(2,''Level 2 Cache '','''512 KB'')

go

插入details_table值(2,''供应商'',''AMD'')

go


插入details_table值(3,''Geometry'',''17 inch'')

go

插入details_table值(3,''屏幕类型'',''平'')

go

插入details_table值(3,'''频率'', '60赫兹'')

go

插入details_table值(3,''供应商'',''戴尔'')

go


创建查看all_view为

选择前100%i.item_id,i.item_name,d.item_key,d.item_value
$ b来自item_table的$ b,因为我在i.item_id = d.item_id上留下了外部联接details_table为$



i.item_id,i.item_name,d.item_key的订单, d.item_value

go


- 完整的搜索是amd socket a 32 bit cache 512 dell


将@ search_key1声明为varchar(50)

将@ search_key2声明为varchar(50)

将@ search_key3声明为varchar(50)

声明@ search_key4为varchar(50)

将@ search_key5声明为varchar(50)

将@ search_key6声明为varchar(50)


set @ search_key1 =''amd''

set @ search_key2 =''socket a''

set @ search_key3 =''32 bit''

设置@sea rch_key4 =''缓存''

设置@ search_key5 =''512''

设置@ search_key6 =''dell''


从all_view中选择不同的item_id



其中

((item_name喜欢''%''+ @ search_key1 +''%' ')或(item_key喜欢''%''+

@ search_key1 +''%'')或(item_value喜欢''%''+ @ search_key1 +''%''))



((item_name喜欢''%''+ @ search_key2 +''%'')或(item_key喜欢''%''+

@ search_key2 +''%'')或(item_value喜欢''%''+ @ search_key2 +''%''))



( (item_name喜欢''%''+ @ search_key3 +''%'')或(item_key喜欢''%''+

@ search_key3 +''%'')或(item_value like' '%''+ @ search_key3 +''%''))



((item_name喜欢''%''+ @ search_key4 +''%''' )或(item_key喜欢''% '+

@ search_key4 +''%'')或(item_value如''%''+ @ search_key4 +''%''))



((item_name喜欢''%''+ @ search_key5 +''%'')或(item_key喜欢''%''+

@ search_key5 +''%' ')或(item_value喜欢''%''+ @ search_key5 +''%''))



((item_name喜欢''%''+ @ search_key6 +''%'')或(item_key喜欢''%''+

@ search_key6 +''%'')或(item_value喜欢''%''+ @ search_key6 +'' %''))

go


----


祝你好评

/>

Dear all, I have illustared with code and sample output data my request
in thsi post. I simply was expecting some results from my search "amd
socket a 32 bit cache 512 dell" that includes a logical AND for all the
words in that search.
Since i assume that any word might be an item_name, item_key or
item_value, i included all in the search.

Can any one tell me why i get 0 results?

The sample output of my data should look like this:

item_id item_nameitem_keyitem_value
--------------------------------------------------
1Gefore MX 440Size64 MB
1Gefore MX 440Architecture64 Bit
1Gefore MX 440AGP8x
1Gefore MX 440ChipsetNvidia
1Gefore MX 440VendorAsus
2AMD 3200+ClassSocket A
2AMD 3200+Speed2 GHz
2AMD 3200+Architecture32 Bit
2AMD 3200+Level 2 Cache512 KB
2AMD 3200+VendorAMD
3Dell P780Geometry17 Inch
3Dell P780Screen TypeFlat
3Dell P780Frequency60 Hz
3Dell P780VendorDell

Here is my scenario:

create table item_table (item_id int identity (1,1) not null primary
key, item_name varchar (50) not null)
go
create table details_table (item_id int not null, item_key varchar
(50), item_value varchar (50))
go
alter table details_table add foreign key (item_id) references
item_table
go

insert into item_table values (''Gefore MX 440'')
go
insert into item_table values (''AMD 3200+'')
go
insert into item_table values (''Dell P780'')
go

insert into details_table values (1,''Size'', ''64 MB'')
go
insert into details_table values (1,''Architecture'', ''64 Bit'')
go
insert into details_table values (1,''AGP'', ''8x'')
go
insert into details_table values (1,''Chipset'', ''Nvidia'')
go
insert into details_table values (1,''Vendor'', ''Asus'')
go

insert into details_table values (2,''Class'', ''Socket A'')
go
insert into details_table values (2,''Speed'', ''2 GHz'')
go
insert into details_table values (2,''Architecture'', ''32 Bit'')
go
insert into details_table values (2,''Level 2 Cache'', ''512 KB'')
go
insert into details_table values (2,''Vendor'', ''AMD'')
go

insert into details_table values (3,''Geometry'', ''17 Inch'')
go
insert into details_table values (3,''Screen Type'', ''Flat'')
go
insert into details_table values (3,''Frequency'', ''60 Hz'')
go
insert into details_table values (3,''Vendor'', ''Dell'')
go

create view all_view as
select top 100 percent i.item_id, i.item_name, d.item_key, d.item_value
from item_table as i left outer join details_table as d
on i.item_id = d.item_id
order by i.item_id, i.item_name, d.item_key, d.item_value
go

-- the complete search is "amd socket a 32 bit cache 512 dell"

declare @search_key1 as varchar (50)
declare @search_key2 as varchar (50)
declare @search_key3 as varchar (50)
declare @search_key4 as varchar (50)
declare @search_key5 as varchar (50)
declare @search_key6 as varchar (50)

set @search_key1 = ''amd''
set @search_key2 = ''socket a''
set @search_key3 = ''32 bit''
set @search_key4 = ''cache''
set @search_key5 = ''512''
set @search_key6 = ''dell''

select distinct item_id
from all_view
where
((item_name like ''%'' + @search_key1 + ''%'') or (item_key like ''%'' +
@search_key1 + ''%'') or (item_value like ''%'' + @search_key1 + ''%''))
and
((item_name like ''%'' + @search_key2 + ''%'') or (item_key like ''%'' +
@search_key2 + ''%'') or (item_value like ''%'' + @search_key2 + ''%''))
and
((item_name like ''%'' + @search_key3 + ''%'') or (item_key like ''%'' +
@search_key3 + ''%'') or (item_value like ''%'' + @search_key3 + ''%''))
and
((item_name like ''%'' + @search_key4 + ''%'') or (item_key like ''%'' +
@search_key4 + ''%'') or (item_value like ''%'' + @search_key4 + ''%''))
and
((item_name like ''%'' + @search_key5 + ''%'') or (item_key like ''%'' +
@search_key5 + ''%'') or (item_value like ''%'' + @search_key5 + ''%''))
and
((item_name like ''%'' + @search_key6 + ''%'') or (item_key like ''%'' +
@search_key6 + ''%'') or (item_value like ''%'' + @search_key6 + ''%''))
go

----

Best regards

推荐答案




第三个标准是32位,它排除了你的前一行你好

结果集,所以你没有得到任何结果。


有更好的方法来做这个设计,但最终,你是

将不得不使用OR作为搜索条件的一部分。


HTH,

Stu



the third criteria is 32 bit, which excludes the previous row from your
result set, so you get no results.

There are much better ways to do this design, but ultimately, you''re
going to have to use an OR as part of your search criteria.

HTH,
Stu





这篇关于我的搜索没有找到结果!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 21:43