0

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
2
  • 2
    select * from table_name order by no limit 1 if this is not what you are looking at describe more about the issue. Commented Aug 13, 2015 at 7:05
  • Welcome to Stack Overflow! You really should take the tour and visit the help center to understand what we expect from our users and their posts. Please edit your question to add your attempt. Commented Aug 13, 2015 at 18:43

4 Answers 4

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I forgot about this issue, but that's work. thanks for your answer.
0

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;

Comments

0

You can use this query for selecting particular row in the table

select * from yourtablename WHERE primarykeyfield=" ";

Comments

0

Try this:

mysql_query("select * from $table where id='1';");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.