Hi,
If you delete a user via the Joomla user manager, the Hikashop user synchronization plugin will delete the entry in hikashop_user, unless the user has orders linked to it. And if it does, it is supposed to set the user_cms_id to 0 automatically.
Now if you delete your joomla users via the database, the synch plugin won't be triggered, and in that case if you click on the "check database" button of the HikaShop configuration, it will resynch the user_cms_id of the users automatically. So you wouldn't have to run that MySQL query in the database.