如何從具有可變列的多個表創建表(聯合不能使用)?如何從多個表中選擇表來創建表?
mysql> select * from a;
+------+------+
| id | name |
+------+------+
| 1 | Ruby |
+------+------+
mysql> select * from b;
+------+------+
| pid | name |
+------+------+
| 1 | Java |
| 1 | C++ |
+------+------+
我想要什麼......
+------+------+------+------+
| id | name | pid | bname|
+------+------+------+------+
| 1 | Ruby | | |
| | | 1 | C++ |
| | | 1 | Java |
+------+------+------+------+
我都試過了。
mysql> create table t as select * from a; # worked fine
mysql> alter table t as select pid, name as bname from b; #didn't work
你爲什麼不能使用'union'? – 2014-08-28 11:00:57
爲什麼你要這樣做呢? – Strawberry 2014-08-28 11:14:55
@Strawberry:我希望它能達到我以前的問題http://stackoverflow.com/questions/25531279/how-do-i-reference-parent-table-in-a-multi-table-join – Bala 2014-08-28 11:41:41