mysql – How to merge two tables

05/02/2018


Given this relation of two tables

table1: (name, height, age)

table2: (cname, weight)

I want to combine name and cname so they are one with no duplicates. Like for example, let’s say the name column for table1 had

name
bob
mary
alice
steve

while the cname column for table2 had

cname
bob
liam
abi
mark

I want to make a new name table like this:

name
bob
mary
alice
steve
liam
abi
mark

My attempt:

SELECT
    name
FROM table1
    JOIN table2
        ON (table1.name = table2.cname)

I’m looking for a better join that’ll make this work? Anyway?

قالب وردپرس