Query to check if row updated/inserted