I have 2 tables with a large number of columns (each has around 700-800 columns, which makes it not feasible to individually write all the column names). Both the tables have a few common rows. I need to dynamically union both the tables such that the common columns don't get repeated and are queried only once in the final table. For example:
TABLE 1:
+---------+--------+------+-------+
|firstname|lastname|upload|product|
+---------+--------+------+-------+
| alice| a| 100|apple |
| bob| b| 23|orange |
+---------+--------+------+-------+
TABLE 2:
+---------+--------+------+-------+
|firstname|lastname|books |active |
+---------+--------+------+-------+
| alice| a| 10 |yes |
| bob| b| 2 |no |
+---------+--------+------+-------+
FINAL TABLE:
+---------+--------+------+-------+-----+------+
|firstname|lastname|upload|product|books|active|
+---------+--------+------+-------+-----+------+
| alice| a| 100|apple | 10 | yes |
| bob| b| 23|orange | 2 | no |
+---------+--------+------+-------+-----+------+
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.