i have table like this .............................
sno name mobile area
1 swapna 9849313821 hyd
2 abilash 987543211 hyd
3 swapna priya 98765313892 vizag
4 shashikiran 9765423111 hyd
5 shashi 9876543211 hyd
6 raju 9876557899 jyd
i want to select only same names ......
sno name mobile area
1 swapna 9849313821 hyd
3 swapna priya 98765313892 vizag
4 shashikiran 9765423111 hyd
5 shashi 9876543211 hyd
Select only same names
4 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Sanjeeb LenkaRank #301 · 8.3K reputationPosted Oct 30, 2013, 12:42 AM EDT
JAYRAMRank #7,836 · 233 reputationPosted Oct 30, 2013, 1:05 AM EDT
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Oct 30, 2013, 3:27 AM EDT
here i used self join in table1.
SELECT t1.name,t1.mobile,t1.area, count(*)
FROM table1 t1
JOIN table1 t2
ON t1.name LIKE '%' + t2.name + '%' or t2.name LIKE '%' + t1.name + '%'
group by t1.name,t1.mobile,t1.area
HAVING count(*) > 1
Priyank Khare154 reputationPosted Nov 7, 2013, 8:19 AM EST
select * from tablename where name like 's%'