tableone
a |b| c
--------
a1 | |c1
a2 | |c2
a3 | |c3
tabletwo
a | b
-----
a1|b1
a2|b2
a3|b3
a4|b4
a5|b5
merged
a | b | c
a1| b1|c1
a2| b2|c2
a3| b3|c3
a4| b4|
a5| b5|
So I have the two table and I want to merge them. I tried in phpmyadmin these two options:
INSERT IGNORE INTO tableone SELECT * FROM tabletwo;
REPLACE INTO tableone SELECT * FROM tabletwo;
But both do the same (put one table on another), but I want to merge them. So what query must I use? I hope you understand the the question…
Try these queries back-to-back:
To answer pst, something like this, assuming that
tableonedoes not have abcolumn:This is untested, but should work. (“Should”…) The UNION is a workaround for MySQL’s lack of FULL OUTER JOIN.