Mysql: Select rows from a table that are not in another

this is a modification of your join query, designed to show you where the dupes are coming from –

SELECT CB.doCode
     , COUNT(*) AS joined_rows
  FROM dotable1 CB
INNER
  JOIN dotable2 A 
    ON A.doCode = CB.doCode
   AND RIGHT(A.doElement, 1) = CB.doElement
 WHERE CB.doType IN ('A')
  AND MONTH(CB.doDate) BETWEEN 1 AND 4
GROUP 
    BY CB.doCode
HAVING COUNT(*) > 1    
1 Like