Fix incorrect SQL manipulation for FK tables.