Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

How to check if two or more rows have the same field value?

I want to filter details from db. Database Example: id| First Name| Last Name1 | Saad | Usama2 | Saad | Usama3 | Saad | def I want to select the first row with the last name "usama" and then I want to skip the next row which has the same field "usama". any ideas ?

user-image
Question added by Usama Saad , Senior Software Engineer (Java) , Saudi Catering Company
Date Posted: 2013/08/22
Haitham Nabil Baioumi
by Haitham Nabil Baioumi , Country Manager , Bolt

------------------------------------------------------------------------------ select * from table_name where last_name = "usama" LIMIT1 ------------------------------------------------------------------------------ this will return the first occurance of last_name usama

Usama Saad
by Usama Saad , Senior Software Engineer (Java) , Saudi Catering Company

IF the table is like id| First_Name| Last_Name 1 | Saad | Usama 2 | Saad | Usama 3 | Saad | def -------------------------------------------------------------------- I found that it could be handled by the below select statment: select min(m.id) Idenfire , m.First_Name, m.Last_Name from new_table m group by m.First_Name, m.Last_Name ----------------------------------------------------------------- Result: 1 | Saad | Usama 3 | Saad | def

حنان يزه
by حنان يزه , متربص , شركة الاتصالات

select * from table_name where last_name="usama";

More Questions Like This

Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.