To do this with a SQL query will not be easy. The "parent ID <-> Category ID" relationship is a complex one in zencart. (A "child" category (sub-category) becomes a "parent" category as well, when a sub-sub-category is added to it.)

Writing this to the two tables involved is not going to be easy - and moreso in your case where the sub-cats are identically named in a lot of instances.

It can be done... but will take some very detailed planning.