避免多次选择的最佳方法 [英] best way for avoiding multiple selects

查看:63
本文介绍了避免多次选择的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

小组,


有没有人得到任何建议来解决这个问题的最佳方法,我已经

得到3张桌子
例如表A,B和C

表A看起来像名字,值

表B看起来像名字,值

表C看起来像变量名,值,值


一个例子是

表A:彼得20

表B :peter 40

表C:var1 20 40

所以从这些树表中我需要填写另一张表(D)以便它看起来如此/>
就像名字,变量名(来自表C)所以在我们的例子中这将是:peter

var1


现在我知道我是怎么做的可以做到这一点,但我只是想知道什么是最好的

方式,表A& B每个包含大约2300个记录,表C大约200个。这个方式

我已经去过这个内部连接表A和B那里的关键列所以

我有一个看起来像peter 20 40的填充数据集,然后我在所有

中读取了表格中2个arraylists中的变量,其中一个包含值和

包含名。然后使用binarysearch在值arraylist中找到正确的元素

(每个值对是唯一的),因此使用

作为名称arraylist的索引,最后一步是保存新记录。对于复杂的解决方案,这是一个

吗?有人提出任何建议吗?


greetz Peter

Hi group,

has anyone got any suggestions fot the best way to handle this problem, I''ve
got 3 tables
for example table A, B, and C
table A looks like name, value
table B looks like name, value
table C looks like variablename, value, value

an example would be
Table A: peter 20
Table B: peter 40
Table C: var1 20 40

so from these tree tables I need to fill an other table (D) so that it looks
like name, variablename(from table C) so in our example this would be: peter
var1

Now I know how I can do this but I was just wondering what would be the best
way, table A & B contain about 2300 records each, table C about 200. The way
I''ve gone about this is to inner join table A and B on there key columns so
I got a filled dataset wich looks like peter 20 40, then I read in all
the variables from table C in 2 arraylists, one containing the values and
one containing the names. then use a binarysearch to find the right element
in the values arraylist(each value pair is unique) and thus the index to use
for the name arraylist, the last step is to save the new record. Is this a
to complex solution? Anyone any suggestions?

greetz Peter

推荐答案

如果我理解你的情况,我会让你的数据库执行

为你工作:


选择A.Column1,C.Column1

来自C

内部加入A在A.Column2 = C.Column2

内部加入B在B.Column2 = C.Column3

其中A.Column1 = B.Column1 < br $>




选择A.Column1,C.Column1

来自A,B,C

其中A.Column2 = C.Column2

和B.Column2 = C.Column3

和A.Column1 = B.Column1


我总是和人们争论哪个会更快,但只有b $ 200 b $ b00记录,你永远不会知道它们之间的区别。


-Zorpy
If I understand your situation correctly, I would let your database do the
work for you:

Select A.Column1, C.Column1
From C
Inner Join A on A.Column2 = C.Column2
Inner Join B on B.Column2 = C.Column3
Where A.Column1 = B.Column1

OR

Select A.Column1, C.Column1
From A, B, C
Where A.Column2 = C.Column2
And B.Column2 = C.Column3
And A.Column1 = B.Column1

I argue with people all the time over which would be faster, but with only
2600 records, you''d never know the difference.

-Zorpy


彼得,


我看了很多次你的问题但是我看不到关系<用VBNet进行
,你能解释一下吗?

Cor
Peter,

I have looked more times too your question however I cannot see the relation
with VBNet, can you explain this more?

Cor


嗨Cor,


首先回复Zorpiedoman和你,

我不能让数据库为我工作因为我没有桌子

C,我必须根据表A生成它和B
Hi Cor,

first to reply Zorpiedoman and also you,
I can''t let the database do the work for me because I haven''t got the table
C, I have to generate it based on the tables A and B
表A看起来像名字,值
表B看起来像名字,值
表C看起来像variablename,value,value


所以我使用vb.net来获取并插入表C中的唯一值对和

之后我使用vb.net来迁移表A& B进入一张桌子(表格D在

我之前的帖子中),所以我希望我现在清除了原来的帖子。


greetz Peter


彼得写道:一个例子是表A:彼得20
表B:彼得40
表C:var1 20 40


但是我首先必须生成表C,忘了提到

所以从这些树表中我需要填写另一个表(D)以便它
看起来像名字,variablename(来自表C)所以在我们的例子中,这将是:
petervar1



" Cor Ligthert" <无************ @ planet.nl>写在消息

新闻:uj ************** @ TK2MSFTNGP11.phx.gbl ...彼得,

我看了你问题的次数多了但是我看不到与VBNet的
关系,你能解释一下这个吗?

table A looks like name, value
table B looks like name, value
table C looks like variablename, value, value
So I use vb.net to get and insert the unique value pairs in in table C and
afterwards I use vb.net to migrate tables A & B into one table (table D in
my previous post), so I hope I cleared my original post now.

greetz Peter

Peter wrote:an example would be
Table A: peter 20
Table B: peter 40
Table C: var1 20 40
but I first have to generate the table C, forgot to mention that
so from these tree tables I need to fill an other table (D) so that it lookslike name, variablename(from table C) so in our example this would be: petervar1

"Cor Ligthert" <no************@planet.nl> wrote in message
news:uj**************@TK2MSFTNGP11.phx.gbl... Peter,

I have looked more times too your question however I cannot see the relation with VBNet, can you explain this more?

Cor



这篇关于避免多次选择的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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