Get rid of the SELECT query. Try UPDATE, on failure INSERT.