angs angs - 5 months ago 8
SQL Question

Merge two tables to one and remove duplicates

I have 2 tables in the same database.

I want to merge them based on the common

id
column. Because the tables are too huge I am not sure if there are duplicates.

How is it possible to merge these two tables into one based on the
id
and be sure that there are no duplicates?

SELECT *
FROM table1,table2
JOIN
GROUP BY id

Answer

I am not sure What exactly do you want but anyway, this is your code

SELECT *
FROM table1,table2
JOIN
GROUP BY id

i just edit your query

SELECT *
FROM table1  JOIN  table2 
 on table2.id = table1.id
GROUP BY table1.id // here you have to add table 
//on which you will be group by at this moment this is table1
Comments