数据示例
表1
Value component1
1 456
表2
Value component2
1 555A
表3
value component3
2 356
输出我
Value component1 component2 component3
1 456 555A
2 356
我想要的输出 - 单独的行
Value component
1 456
1 555A
2 356
答案 0 :(得分:0)
您可以使用这样的联合:
SELECT * FROM TableA
UNION
SELECT * FROM TableB
UNION
SELECT * FROM TableC
UNION
SELECT * FROM TableD
如果您需要更多信息,请参阅此页面: use union
答案 1 :(得分:0)
您可以使用 UNION ALL 并使别名与每个表上的参数相同。请参阅以下内容:
SELECT `value`,`component1` as 'component' FROM `table1`
UNION ALL
SELECT `value`,`component2` as 'component' FROM `table2`
UNION ALL
SELECT `value`,`component3` as 'component' FROM `table3`
您需要在要合并的每个表上设置相同的表达式/别名。 如果您想了解更多信息,请参阅此链接 MySQL Union and Union All Operators Primer
答案 2 :(得分:0)
word = input("Enter a word: ")
for i in word:
print(i)
答案 3 :(得分:0)
关于你到目前为止所说的话,TO_CHAR可能有所帮助。
SQL> create table table1 (value number, component1 number);
Table created.
SQL> create table table2 (value number, component2 varchar2(20));
Table created.
SQL> create table table3 (value number, component3 number);
Table created.
SQL> insert all
2 into table1 values (1, 456)
3 into table2 values (1, '555A')
4 into table3 values (2, 356)
5 select * From dual;
3 rows created.
SQL>
SQL> select t1.value, to_char(t1.component1) component from table1 t1 union
2 select t2.value, t2.component2 from table2 t2 union
3 select t3.value, to_char(t3.component3) from table3 t3;
VALUE COMPONENT
---------- ----------------------------------------
1 456
1 555A
2 356
SQL>