Checking for duplicate entries for Column A - Table A based on user_id from Table B I have two tables which have a 1 - 1 relationship.

Table A - Skill_id
Tabel A - Entry_id

Table B - Entry_id
Table B - Author_id

The two entry_id columns are a primary key - foreign key.

I need to check if a user has been allocated the same skill more than once, i.e. if there are duplicates. How can I achieve this?
Do a GROUP BY aggregation and see if the aggregated count is greater than 1

SELECT B.Author_id,A.Skill_id,COUNT(1) SkillEntryCount
FROM tableB B INNER JOIN tableA A USING (Entry_id)
GROUP BY B.Author_id,A.Skill_id
HAVING COUNT(1) &gt; 1;


or collect all entry_id values for each (Author_id,Skill_id) and see it is has commas

SET group_concat_max_len = 1048576;
SELECT * FROM
(
  SELECT B.Author_id,A.Skill_id,GROUP_CONCAT(A.Entry_id) EntryIDs
  FROM tableB B INNER JOIN tableA A USING (Entry_id)
  GROUP BY B.Author_id,A.Skill_id
) AA WHERE LOCATE(',',EntryIDs) &gt; 0;