<?xml version="1.0" encoding="ISO-8859-1"?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>Geeks Talk - SQL</title>
		<link>http://www.geekinterview.com/talk/</link>
		<description />
		<language>en</language>
		<lastBuildDate>Sat, 21 Nov 2009 18:59:15 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>http://www.geekinterview.com/talk/images/misc/rss.jpg</url>
			<title>Geeks Talk - SQL</title>
			<link>http://www.geekinterview.com/talk/</link>
		</image>
		<item>
			<title>How to use union clause to eliminate duplicates</title>
			<link>http://www.geekinterview.com/talk/16538-how-use-union-clause-eliminate-duplicates.html</link>
			<pubDate>Sun, 15 Nov 2009 18:40:20 GMT</pubDate>
			<description>Hello, 
 
I have 2 tables. 
From table 1 the columns which i need to display are 
Table 1 columns-...</description>
			<content:encoded><![CDATA[<div>Hello,<br />
<br />
I have 2 tables.<br />
From table 1 the columns which i need to display are<br />
Table 1 columns- a_name,a_addressa,a_addressb,a_addressc,a_city,a_taluk.a_district,a_pin(all varchar2).<br />
Table has 2859 rows.<br />
<br />
From table 2 the columns which i need to display are<br />
Table 2 columns- b_name,b_Add1,b_Add2,b_Add3,b_Add4,b_Add5,b_City,b_pin(all varchar2)<br />
Table 2 has 1036 rows.<br />
<br />
So now there are some names which may belong to both the tables.So i need to eliminate that.So based on Name and address i need to eliminate duplicate rows.Because 2 people can have same name also.So just i cant take name.<br />
Even if name and address is same then i want to take only once that data.<br />
<br />
I am using the query like this<br />
select a_name, a_addressa||','||a_addressb||','||a_addressc, a_city||','||a_taluk||','||a_dist, a_pin from table_a<br />
union<br />
select b_name, b_add1||','||b_add2||','||b_add3||','||b_add4||','||b_add5, b_city, b_pin from table_b<br />
<br />
sample Data in table_a is                          <br />
a_name=Seema T.N.<br />
a_addressa=No 112/3,Seema House<br />
a_addressb=3 rd Cross,Near FTM bakery <br />
a_addressc=Palam Colony<br />
a_city=Delhi<br />
a_taluk=Delhi<br />
a_dist=Delhi<br />
a_pin=110010<br />
<br />
sample Data in table_b is <br />
b_name=Seema T.N.<br />
b_add1=No 112/3<br />
b_add2=Seema    House<br />
b_add3=3 rd Cross<br />
b_add4=Near FTM bakery<br />
b_add5=PalamColony<br />
b_city=Delhi<br />
b_pin=110010<br />
<br />
Here i am considering a data where same person is present in both the tables.<br />
But still the query which i have written its returns 2 rows.Because while entering the data in table_b,some extra spaces would have been added or some words may be combined,some words may be missed.<br />
<br />
Actually it should written me only one row.<br />
But still since i am concatenating the address the duplicates are still coming.<br />
<br />
How can i do this?</div>

]]></content:encoded>
			<category domain="http://www.geekinterview.com/talk/sql/">SQL</category>
			<dc:creator>swapna053</dc:creator>
			<guid isPermaLink="true">http://www.geekinterview.com/talk/16538-how-use-union-clause-eliminate-duplicates.html</guid>
		</item>
	</channel>
</rss>
