Correct SQL where clause (merge error)