add LIMIT 1 for select with key logic