Use the INSERT INTO command combined with the UNION command to filter out the duplicates. MySQL Server doesn't support the SELECT ... INTO TABLE which you may have stumbled across on several SQL Tutorial sites:
http://dev.mysql.com/doc/r
INSERT INTO C(KEY_C, VAL_C)
SELECT KEY_A, VAL_A FROM A
UNION
SELECT KEY_B, VAL_B FROM B ORDER By KEY_A
Note that if the two duplicate KEY_? columns have different VALUE_? values. These rows will be treated as different and both included in the SELECT... UNION result.
Main Topics
Browse All Topics





by: sujith80Posted on 2007-07-16 at 23:35:15ID: 19502568
insert into C
select key_a, val_a from A
union
select key_b, val_b from B
/