'how to remove duplicate from UNION Query result?
I have two tables :
Table1
id | name | tech
-----------------
1 | jose | python
2 | rolf | java
3 | alain| scala
Table2
id | name | tech
-----------------
4 | jose | haskell
5 | rolf | c++
6 | sylvie|js
I want to merge them with a UNION and get the name only from the first table so the result should be like that:
id | name | tech
-----------------
1 | jose | python
2 | rolf | java
3 | alain| scala
4 | sylvie|js
Solution 1:[1]
Use a WHERE clause.
select id, name, tech from table1
union all
select id, name, tech from table2 where name not in (select name from table1);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Thorsten Kettner |
