Migrate posts from category and sub-category via SQL

I strongly suspect the reason you want SQL that you haven’t mentioned/shared, is because you can’t use the WP functions to fetch the posts and do it manually in a single request due to the PHP time execution limit, or you don’t know how to.

Sadly, doing it via SQL is no guarantee this will work, additionally, you’ll break all the caches involved, all the term post counts will be broken, and a few other things too.

The best way to do this, is with WP CLI, for example here we take all posts in category X, put them in category Y, then remove them from X:

# get all the post IDs in category x
posts=wp post list --category_name="x" --field="ID"

# Move them from x to Y
for id in $posts
do
  wp post term remove $id cat "x" --by="slug"
  wp post term add $id cat "y" --by="slug"
done

But given you’ve hinted you’re actually doing this by year, it might be easier to simply rename the terms, so 2010 -> 2009, 2011 -> 2010 etc. This would be much much faster/reliable/simpler.