The select is probably unnecessary. Try UPDATE. If no affected rows, do INSERT.