mysql - Merging 2 tables with different field name -
select * 'batcha'
table 'batcha' +--------+--------+--------+ |fruits | color | class | +--------+--------+--------+ | | | | |apple | red | x | |apple | yellow | x | |guava | green | o | +--------+--------+--------+
select * 'batchb' table 'batchb'
+--------+--------+--------+ |fruitsb | size | type | +--------+--------+--------+ | | | | | apple | large | | | guava | medium | b | | guava | small | c | +--------+--------+--------+
is possible query join or union using these results?
result
+--------+--------+--------+--------+--------+--------+ |fruits | color | class |animals | size | type | +--------+--------+--------+--------+--------+--------+ | | | | | | | | apple | red | x | | | | | apple | yellow | x | | | | | | | | apple | large | | | guava | green | o | | | | | | | | guava | medium | b | | | | | guava | small | c | +--------+--------+--------+--------+--------+--------+
sure, can use union
select batcha.*,null animals,null size,null type batcha union select null,null,null,batchb.* batchb;
this list rows both tables nulls fields aren't populated.
this under assumption there no relation between tables.
Comments
Post a Comment