I am using union all
in my code something like
select * from country
union all
select * from city
If same entry is there in both the select, then it should count only once.
I am using union all
in my code something like
select * from country
union all
select * from city
If same entry is there in both the select, then it should count only once.
Use UNION
instead:
select * from country
union
select * from city
This will effectively filter out any duplicate records.
If you do not need duplicate you should use union not union all
select distinct * from country
union
select distinct * from city
edit: You must be getting the duplicate values from country table. Now I've changed my query according to your requirement
First of all don't do SELECT *
and select only the columns you need. UNION should remove duplicates.
select col1, col2 from country
union
select col1, col2 from city