+2 votes
in Databases by (14.2k points)
When I combine the results of multiple queries into a single result using the UNION operator, I do not see duplicate records in the result. I need to keep the duplicate records in the query output, how to keep them?

1 Answer

0 votes
by (22.1k points)

If you want to keep duplicate records in the result, you need to use UNION ALL instead of UNION. By defaults, UNION operator removes all duplicate records.


SELECT a,b,c FROM table1


SELECT a,b,c FROM table2