我的搜索没有找到结果! [英] No results found for my search!

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

问题描述

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

在帖子中。我只是期待我的搜索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_name item_key item_value
--------------------------------------------------
1 Gefore MX 440 Size 64 MB
1 Gefore MX 440 Architecture 64 Bit
1 Gefore MX 440 AGP 8x
1 Gefore MX 440 Chipset Nvidia
1 Gefore MX 440 Vendor Asus
2 AMD 3200+ Class Socket A
2 AMD 3200+ Speed 2 GHz
2 AMD 3200+ Architecture 32 Bit
2 AMD 3200+ Level 2 Cache 512 KB
2 AMD 3200+ Vendor AMD
3 Dell P780 Geometry 17 Inch
3 Dell P780 Screen Type Flat
3 Dell P780 Frequency 60 Hz
3 Dell P780 Vendor Dell

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

推荐答案

您没有任何一条符合您所有条件的记录。让我这么快就试着让你快速通过它:


您的数据:
You don''t have any one record that matches all of your criteria. Let
me try to step you through it real quick:

Your data:
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供应商戴尔


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



您的WHERE子句:

((item_name类似''%''+ @ search_key1 +''%'')或(item_key比如''%''+
@ search_key1 +''%'')或(item_value喜欢''%''+ @ search_key1 +''%''))


crieria 1发现其中包含AMD的所有行:

2 AMD 3200+ Class Socket A
2 AMD 3200+ Speed 2 GHz
2 AMD 3200+架构32位
2 AMD 3200+ 2级缓存512 KB
2 AMD 3200+供应商AMD



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


使用并进一步缩小结果集以找到行

,第二个标准:socket a

2 AMD 3200+ Class Socket A
item_id item_name item_key item_value
--------------------------------------------------
1 Gefore MX 440 Size 64 MB
1 Gefore MX 440 Architecture 64 Bit
1 Gefore MX 440 AGP 8x
1 Gefore MX 440 Chipset Nvidia
1 Gefore MX 440 Vendor Asus
2 AMD 3200+ Class Socket A
2 AMD 3200+ Speed 2 GHz
2 AMD 3200+ Architecture 32 Bit
2 AMD 3200+ Level 2 Cache 512 KB
2 AMD 3200+ Vendor AMD
3 Dell P780 Geometry 17 Inch
3 Dell P780 Screen Type Flat
3 Dell P780 Frequency 60 Hz
3 Dell P780 Vendor Dell

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

Your WHERE clause:
((item_name like ''%'' + @search_key1 + ''%'') or (item_key like ''%'' +
@search_key1 + ''%'') or (item_value like ''%'' + @search_key1 + ''%''))
crieria 1 finds all rows that have AMD in them:
2 AMD 3200+ Class Socket A
2 AMD 3200+ Speed 2 GHz
2 AMD 3200+ Architecture 32 Bit
2 AMD 3200+ Level 2 Cache 512 KB
2 AMD 3200+ Vendor AMD
and
((item_name like ''%'' + @search_key2 + ''%'') or (item_key like ''%'' +
@search_key2 + ''%'') or (item_value like ''%'' + @search_key2 + ''%''))
the use of the and further narrows down your resultset to finding rows
with the second criteria: socket a
2 AMD 3200+ Class Socket A




第三个标准是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


感谢您的回复,使用OR它会起作用,但我认为因为item_table和details_table之间的

关系是1-M所以那些

许多细节都在一个或多个项目中。有没有办法在所有这些中找到

的结果?

实际上item_id 2是AMD 3200 +确实有它

所有细节" amd socket 32​​ bit cache 512 dell"除了dell

和item_id 3,它是Dell P780。在它下面有dell;怎么可以包括所有没有OR?

我的理由是用户搜索会假设他会得到一个

包括全部的结果作为必须而非选择。


最好的问候

Thanks for replying, Well with OR it will work, but i think because the
relationship between item_table and details_table is 1-M so all those
many details are within one or more items. Is there a way to find
results within all of them?
Actually the item_id 2 which is "AMD 3200+" does indeed have under it
all of the details "amd socket a 32 bit cache 512 dell" except "dell"
and item_id 3 which is "Dell P780" has under it the word "dell"; how is
it possible to include all without "OR"?
My reasoning is that the user searching will assume that he will get a
result that includes "All" as a must and not optional.

Best regards





coosa写道:


coosa wrote:
感谢您的回复,好吧,或者它会起作用,但我认为因为item_table和details_table之间的关系是1-M所以所有那些
很多细节在一个或多个项目内。有没有办法在所有这些内找到
结果?
实际上是item_id 2,它是AMD 3200 +。确实有它的所有细节amd socket a 32 bit cache 512 dell除了dell
和item_id 3,它是Dell P780。在它下面有dell;如何在没有OR的情况下包括所有内容?


如果您要求匹配''dell''的商品,您将获得

商品仅与''dell''相匹配,而您不会回到第2项。


能否请您显示您想要的确切结果,因为它听起来像

您不希望使用的结果并且,但是你不想要使用OR的结果

。但是你的描述在所有这些内容中找到结果

并不完全准确。如果你给出了几个例子,那将会有所帮助

其中OR和AND都没有给你你想要的结果。

Steve Kass

Drew University

我的理由是用户搜索将假设他将获得包含全部的结果。最好的问候
Thanks for replying, Well with OR it will work, but i think because the
relationship between item_table and details_table is 1-M so all those
many details are within one or more items. Is there a way to find
results within all of them?
Actually the item_id 2 which is "AMD 3200+" does indeed have under it
all of the details "amd socket a 32 bit cache 512 dell" except "dell"
and item_id 3 which is "Dell P780" has under it the word "dell"; how is
it possible to include all without "OR"?
If you request items matching ''dell'', you will get back
items matching ''dell'' only, and you won''t get back item #2.

Can you please show the exact result you want, since it sounds like
you don''t want the result of using AND, but you don''t want the result
of using OR. But your description "find results within all of them"
is not at all precise. It would help if you gave several examples
where neither OR nor AND gives you the results you want.
Steve Kass
Drew University
My reasoning is that the user searching will assume that he will get a
result that includes "All" as a must and not optional.

Best regards



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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆