This query is probably unnecessary. Use UPDATE, get the affected row count, then send an INSERT of necessary.