Working on MySQL logic for the 3 queries in unduplicate.py