Reputation: 90
I have duplicate data on my table as described bellow.
no name adrress
1 Joe No.3
2 Joe No.2
3 Joe No.1
4 Anna No.4
5 Anna No.5
6 Ali No.6
I want to show only the first item from duplicate data like bellow.
no name address
1 Joe No.3
2 Anna No.4
Upvotes: 0
Views: 142
Reputation: 505
If you mean to find the duplicate only, this one similar to your question here
for your case will be like this
SELECT x.*
FROM new_table x
JOIN
( SELECT name
, MIN(id) as min_id , COUNT(id) as count_id
FROM new_table
GROUP
BY name
) y
ON y.name = x.name
AND y.min_id = x.id
AND y.count_id > 1
ORDER
BY id;
hope that answer your question.
Upvotes: 1
Reputation: 1
You can use this query for selecting particular row in the table
select * from yourtablename WHERE primarykeyfield=" ";
Upvotes: 0
Reputation: 14064
There could be lot of answers to this question see which one fits your requirements:
Select * from tablename where no=1;
Select * from tablename where adrress LIKE "%3%";
Select * from tablename ORDER BY no LIMIT 1;
Upvotes: 0