可以创建这种格式吗? [英] Can this format be created?

查看:85
本文介绍了可以创建这种格式吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2张桌子:


Table1包含(其中包括):


ID Data1 Data2 Data3

1 aaa bbb ccc

2 ddd eee fff

3 ggg hhh iii


表2包含(其中包括:


ID Key Value

1 20 zzz

1 30 yyy

1 40 xxx

2 20 www

2 30 vvv

2 40 uuu

3 20 ttt

3 30 sss

3 40 rrr


我需要一个返回的查询:


ID Data1 Data2 Data3 Value Value价值

(关键= 20)(关键= 30)(关键= 40)

1 aaa bbb ccc zzz yyy xxx

2 ddd eee fff www vvv uuu

3 ggg hhh iii ttt sss rrr


有什么想法吗?


谢谢推进正确的方向! :)

I have 2 tables:

Table1 contains (among other things):

ID Data1 Data2 Data3
1 aaa bbb ccc
2 ddd eee fff
3 ggg hhh iii

Table2 contains (among other things:

ID Key Value
1 20 zzz
1 30 yyy
1 40 xxx
2 20 www
2 30 vvv
2 40 uuu
3 20 ttt
3 30 sss
3 40 rrr

I need a query that returns:

ID Data1 Data2 Data3 Value Value Value
(Key=20) (Key=30) (Key=40)
1 aaa bbb ccc zzz yyy xxx
2 ddd eee fff www vvv uuu
3 ggg hhh iii ttt sss rrr

Any ideas?

Thanks in advance for a push in the right direction! :)

推荐答案

我能想到的唯一方法是在存储过程中使用编程

来构建它''手动'',但这取决于你正在使用什么样的RDBMS



你能否将表2的数据存储在三元组中与表1相同?那个

那么简单。


数据与你想要使用的方式之间似乎有争执

它。您确定需要以这种方式存储数据吗?你没有给出

你的能力的任何迹象,这可能是另一种方法

比解决方案更好。

Bill H写道:
The only way I can think of is to use programming in a stored procedure
to literally build it ''manually'', but that depends on what kind of RDBMS
you''re using.

Are you able to store table 2 data in triplets the same as table 1? That
would be easy then.

There seems to be a fight between the data and the way you want to use
it. Are you sure you need to store your data that way? You don''t give
any indication of your abilities and it might be that another approach
is better than a solution.
Bill H wrote:
我有2个表:

Table1包含(其中包括):

ID Data1 Data2 Data3
1 aaa bbb ccc
2 ddd eee fff
3 ggg hhh iii

表2包含(其中包括:

ID键值
1 20 zzz
1 30 yyy
1 40 xxx
2 20 www
2 30 vvv
2 40 uuu
3 20 ttt
3 30 sss
3 40 rrr

我需要一个返回的查询:

ID Data1 Data2 Data3 Value Value Value
(Key = 20)(Key = 30) (关键= 40)
1 aaa bbb ccc zzz yyy xxx
2 ddd eee fff www vvv uuu
3 ggg hhh iii ttt sss rrr

任何想法?

提前感谢您推动正确的方向! :)
I have 2 tables:

Table1 contains (among other things):

ID Data1 Data2 Data3
1 aaa bbb ccc
2 ddd eee fff
3 ggg hhh iii

Table2 contains (among other things:

ID Key Value
1 20 zzz
1 30 yyy
1 40 xxx
2 20 www
2 30 vvv
2 40 uuu
3 20 ttt
3 30 sss
3 40 rrr

I need a query that returns:

ID Data1 Data2 Data3 Value Value Value
(Key=20) (Key=30) (Key=40)
1 aaa bbb ccc zzz yyy xxx
2 ddd eee fff www vvv uuu
3 ggg hhh iii ttt sss rrr

Any ideas?

Thanks in advance for a push in the right direction! :)






我能想到的唯一方法就是在存储过程中使用编程

可以手动构建它,但这取决于你正在使用什么样的RDBMS




你能够将表2中的数据存储在与表1相同的三元组中?那个

那么简单。


数据与你想要使用的方式之间似乎有争执

它。您确定需要以这种方式存储数据吗?你没有给出

你的能力的任何迹象,这可能是另一种方法

比解决方案更好。

Bill H写道:
The only way I can think of is to use programming in a stored procedure
to literally build it ''manually'', but that depends on what kind of RDBMS
you''re using.

Are you able to store table 2 data in triplets the same as table 1? That
would be easy then.

There seems to be a fight between the data and the way you want to use
it. Are you sure you need to store your data that way? You don''t give
any indication of your abilities and it might be that another approach
is better than a solution.
Bill H wrote:
我有2个表:

Table1包含(其中包括):

ID Data1 Data2 Data3
1 aaa bbb ccc
2 ddd eee fff
3 ggg hhh iii

表2包含(其中包括:

ID键值
1 20 zzz
1 30 yyy
1 40 xxx
2 20 www
2 30 vvv
2 40 uuu
3 20 ttt
3 30 sss
3 40 rrr

我需要一个返回的查询:

ID Data1 Data2 Data3 Value Value Value
(Key = 20)(Key = 30) (关键= 40)
1 aaa bbb ccc zzz yyy xxx
2 ddd eee fff www vvv uuu
3 ggg hhh iii ttt sss rrr

任何想法?

提前感谢您推动正确的方向! :)
I have 2 tables:

Table1 contains (among other things):

ID Data1 Data2 Data3
1 aaa bbb ccc
2 ddd eee fff
3 ggg hhh iii

Table2 contains (among other things:

ID Key Value
1 20 zzz
1 30 yyy
1 40 xxx
2 20 www
2 30 vvv
2 40 uuu
3 20 ttt
3 30 sss
3 40 rrr

I need a query that returns:

ID Data1 Data2 Data3 Value Value Value
(Key=20) (Key=30) (Key=40)
1 aaa bbb ccc zzz yyy xxx
2 ddd eee fff www vvv uuu
3 ggg hhh iii ttt sss rrr

Any ideas?

Thanks in advance for a push in the right direction! :)






第二个想法,你需要一个交叉表查询
http://dev.mysql.com/tech-resources/...ard/index .html

Lord Yoda写道:
On second thoughts, you need a crosstab query
http://dev.mysql.com/tech-resources/...ard/index.html
Lord Yoda wrote:
我能想到的唯一方法就是在存储过程中使用编程来
字面意思是手动构建它,但这取决于你正在使用什么样的RDBMS。

你是否能够将表2数据存储在与表1相同的三元组中?那么
会很容易。

数据和你想要使用它的方式之间似乎存在斗争。您确定需要以这种方式存储数据吗?你没有给出任何关于你的能力的指示,这可能是另一种方法
比解决方案更好。

Bill H写道:
The only way I can think of is to use programming in a stored procedure
to literally build it ''manually'', but that depends on what kind of RDBMS
you''re using.

Are you able to store table 2 data in triplets the same as table 1? That
would be easy then.

There seems to be a fight between the data and the way you want to use
it. Are you sure you need to store your data that way? You don''t give
any indication of your abilities and it might be that another approach
is better than a solution.
Bill H wrote:
我有2个表:

Table1包含(其中包括):

ID Data1 Data2 Data3
1 aaa bbb ccc 2 ddd eee fff
3 ggg hhh iii

表2包含(其中包括:

ID键值
1 20 zzz
1 30 yyy
1 40 xxx
2 20 www
2 30 vvv
2 40 uuu
3 20 ttt
3 30 sss
3 40 rrr

我需要一个返回的查询:

ID Data1 Data2 Data3 Value Value Value
(Key = 20)(Key = 30)(Key = 40 )
1 aaa bbb ccc zzz yyy xxx
2 ddd eee fff www vvv uuu
3 ggg hhh iii ttt sss rrr

任何想法?

提前感谢您推动正确的方向! :)
I have 2 tables:

Table1 contains (among other things):

ID Data1 Data2 Data3
1 aaa bbb ccc
2 ddd eee fff
3 ggg hhh iii

Table2 contains (among other things:

ID Key Value
1 20 zzz
1 30 yyy
1 40 xxx
2 20 www
2 30 vvv
2 40 uuu
3 20 ttt
3 30 sss
3 40 rrr

I need a query that returns:

ID Data1 Data2 Data3 Value Value Value
(Key=20) (Key=30) (Key=40)
1 aaa bbb ccc zzz yyy xxx
2 ddd eee fff www vvv uuu
3 ggg hhh iii ttt sss rrr

Any ideas?

Thanks in advance for a push in the right direction! :)






这篇关于可以创建这种格式吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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