Skip to content Skip to sidebar Skip to footer

Find Duplication In Multi Tables

We have 4 tables Student, School, Location and StudentSchool Students can can have same name but they are different persons each student can be in one school only and each school l

Solution 1:

You only need to search one table

select student_id 
  from school_student 
 groupby student_id
havingcount(*) >1

Solution 2:

In the result, group students by name (group by in SQL), producing their count in the group (count(*) in SQL), then filter only those who have count > 1 (having count(*) > 1 in SQL).

I don't know how to express it in the query building tool, but it must support it.

Note that such grouping will lose IDs and school names; you will have to query for them again using the names.

Post a Comment for "Find Duplication In Multi Tables"