我有两张这样的桌子,
表格1 :
+-------------+--------+--------+--------+
| contract_id | price1 | price2 | price3 |
+-------------+--------+--------+--------+
| 1 | 23 | 45 | 56 |
| 1 | 22 | 21 | 453 |
| 1 | 45 | 564 | 456 |
| 4 | 22 | 21 | 453 |
| 5 | 45 | 564 | 456 |
+-------------+--------+--------+--------+
和表2,
+-------------+--------+---------+
| contract_id | owner | address |
+-------------+--------+---------+
| 1 | Me | Madras |
| 1 | father | Chennai |
+-------------+--------+---------+
我想将两个表拼接在一起,结果看起来像,
+-------------+--------+--------+--------+--------+---------+
| contract_id | price1 | price2 | price3 | owner | address |
+-------------+--------+--------+--------+--------+---------+
| 1 | 23 | 45 | 56 | Me | Madras |
| 1 | 22 | 21 | 453 | father | Chennai |
| 1 | 45 | 564 | 456 | NULL | NULL |
| 4 | 22 | 21 | 453 | NULL | NULL |
| 5 | 45 | 564 | 456 | NULL | NULL |
+-------------+--------+--------+--------+--------+---------+
目前我正在手动迭代第二个表并更新第一个表中的相应行以实现这一点。我想出的其他方法是进行外部联接并清理重复的行。有没有更好的方法来获得结果?