I have two columns in one table. Let's say they are: Chelsea (as column1) and Brazil (as column2).
我有两个列在一个表中。让我们假设他们是:切尔西(如哥伦布)和巴西(如哥伦布)。
Rows in these two columns are players (both have 11 rows). As we know, there might be the case when the same player is in both columns (e.g. Ramirez, because he plays for Chelsea and is Brazilian). And my question is how to create a new column in which every player from these two columns will appear (so this new column will have 22 rows, i.e. duplicates are allowed) and instead of their names, every row will be saying whether they are right- or left-footed players.
这两列中的行是参与者(都有11行)。正如我们所知道的那样,当同一名球员在两列(例如拉米雷斯,因为他为切尔西踢球,是巴西人)时,情况可能会发生变化。我的问题是如何创建一个新的列,在这个列中,这两个列中的每个参与者都将出现(所以这个新列将有22行,即允许重复),而不是他们的名字,每一行都将说明他们是正确的还是左脚的球员。
If football case doesn't appeal to you, let's say we have Miami Heat (column 1, 5 rows) and the US national team (column 2, 5 rows). In both columns, we will obviously have LeBron James and I would like to create a new table saying if every player is right- or left-handed (10 rows)
如果橄榄球赛对你没有吸引力,那就假设我们有迈阿密热队(第一栏,五排)和美国国家队(第二栏,五排)。在这两栏中,我们将会看到勒布朗·詹姆斯和我想要创造一个新桌子,说如果每个球员都是对的,或者是左撇子(10行)
Hope anyone understands me ;)
希望有人能理解我;
Thanks for help!
谢谢你的帮助!
1 个解决方案
#1
2
If you want to combine result from of two columns you should use the union
如果您想要合并两列的结果,您应该使用union。
Select column1 from table
union all
select column2 from table;
This will produce the result. As for the second part its defer from the db you use. But what you have to do is wrap about query into block and from that block in select part you should add a decision that do the job.
这将产生结果。至于第二部分,它是由你使用的db来决定的。但是你要做的是将查询打包到block中,然后在select部分中,你应该添加一个做这个工作的决定。
#1
2
If you want to combine result from of two columns you should use the union
如果您想要合并两列的结果,您应该使用union。
Select column1 from table
union all
select column2 from table;
This will produce the result. As for the second part its defer from the db you use. But what you have to do is wrap about query into block and from that block in select part you should add a decision that do the job.
这将产生结果。至于第二部分,它是由你使用的db来决定的。但是你要做的是将查询打包到block中,然后在select部分中,你应该添加一个做这个工作的决定。