sovler sovler - 2 years ago 111
MySQL Question

Mysql: how to merge two table with same low and different column

I have two tables. They have same rows and different columns. For example,

Table 1

id / fruit

1 / apple

2 / grape

3 / banana


Table 2

id / price / city

1 / 100 / Newyork

2 / 200 / LA

3 / 150 / DC


How can I merge above two tables and create new table?

It means, I expect this result

id / fruit / price / city

1 / apple / 100 / Newyork

2 / grape / 200 / LA

3 / banana / 150 / DC

Answer Source

You can use the inner join

SELECT t1.id, t1.fruit,t2.price,t2.city FROM t1 
INNER JOIN t2 ON t1.id = t2.id
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download