I have a MySQL table with a very large data.  What I need is to find and separate duplicates from the unique rowsLet's say this is my table:indx, data_lname, data_fname, data_mname, data_dob, data_mobileWhat I'm doing right now is selecting all the rows in one query and then comparing each row with the same table using a different query.  This works ok but slow as hell.Can this be done with a single query?private sub poplist()    DBstrSQL = SELECT * from tbl_data order by indx asc    Dim myCmd As New MySqlCommand    myCmd.CommandTimeout = 300    myCmd.CommandText = DBstrSQL    myCmd.Connection = MySqlConn    Dim myReader As MySqlDataReader = myCmd.ExecuteReader()    If myReader.HasRows = True Then          While myReader.Read()             if checkifdup(myReader.GetString(indx),myReader.GetString(data_fname),myReader.GetString(data_mname),myReader.GetString(data_lname),myReader.GetString(data_dob),myReader.GetString(data_mobile))=false then                          With lstUnique.Items.Add(myreader.getstring(data_lname))                           .SubItems.Add(myreader.getstring(data_fname))                           .SubItems.Add(myreader.getstring(data_mname))                           .SubItems.Add(myreader.getstring(data_dob))                           .SubItems.Add(myreader.getstring(data_mobile))                          End With             else                          With lstDup.Items.Add(myreader.getstring(data_lname))                           .SubItems.Add(myreader.getstring(data_fname))                           .SubItems.Add(myreader.getstring(data_mname))                           .SubItems.Add(myreader.getstring(data_dob))                           .SubItems.Add(myreader.getstring(data_mobile))                          End With             end if          End While    end if    myReader.Close()end subprivate function checkifdup(dataindx sa string, data1 as string,data2 as string, data3 as string, data4 as string, data5 as string) as boolean    myCmd.CommandText = SELECT * from tbl_data where indx<>@indx and data_lname=@lname and data_mname=@mname and data_fname=@fname and (date_format(data_dob,'%m-%d-%Y')=@dob or data_mobile=@mobile) limit 1    myCmd.Prepare()    myCmd.Parameters.AddWithValue(@lname, data3)    myCmd.Parameters.AddWithValue(@mname, data2)    myCmd.Parameters.AddWithValue(@fname, data1)    myCmd.Parameters.AddWithValue(@dob, data4)    myCmd.Parameters.AddWithValue(@mobile, data5)    myCmd.Parameters.AddWithValue(@indx, dataindx)    Dim myReader As MySqlDataReader = myCmd.ExecuteReader()    If myReader.HasRows = True Then          myReader.Close()          return True    Else          myReader.Close()          return false    End Ifend function
Separating Duplicates from Uniques
beginner;mysql;vb.net