Fix WHERE string construction