Fixed SQL join

Doesn't return duplicates