MySQL例程编程,多表和字符串操作

时间:2013-02-07 11:10:11

标签: mysql procedure

好吧,这是我遇到的一个问题......很难解释但我会尽力做到最好!

我有一个包含2个表格的数据库:

1班级表

classname | points                     | max | min
_____________________________________________________
Land      | tree,bush,house            | 1   | 0.2
Sea       | fish,water                 | 1   | 0.3
Air       | bird,plane,moon,sun,clouds | 1   | 0.5

2数据表:

ID | classname | points
___________________________
5  | Land      |
6  | Land      |
9  | Land      |
11 | Sea       |
15 | Sea       |
20 | Air       |
1  | Land      |

类表中包含数据表的所有可能的类名 如果points列有行为空的行,则应按照以下结果进行编辑...


现在应该是什么结果:

数据表:

ID | classname | points
_________________________________________________________
5  | Land      | [["tree",A],["bush",B],["house",C]]
6  | Land      | [["tree",D],["bush",E],["house",F]]
9  | Land      | [["tree",G],["bush",H],["house",I]]
11 | Sea       | [["fish",F],["water",G]]
15 | Sea       | [["fish",H],["water",I]]
20 | Air       | [["bird",J],["plane",K],["moon",L],["sun",M],["clouds",N]]
1  | Land      | [["tree",O],["bush",P],["house",Q]]

点列中A-Q的字母应该是类表的最小值和最大值之间的随机十进制数

如果有人可以帮助我解决这个问题,那将非常感激,如果有任何进一步的信息需要请求!

我是初学者:S

1 个答案:

答案 0 :(得分:0)

我不太确定但是先看看桌子告诉我这种关系可能是错的。 但这取决于您的需求。我无法理解整个问题,但尝试将classtable ID存储在datatable中。