Figured it out with a little experimenting.
When you create a category in WordPress, there will be a category ID# for the new catgory(nothing new about that, of course). Find your ID# by hovering your cursor over the category link name on the category page and check your browser's status bar (something like
There are three relevant tables in the database which are all updated each time you add/remove/change a category:
In wp_terms, you'll find a field called term_id. Each category is listed with its category # as the term_id, and these are linked with the category name and slug.
The table wp_term_taxonomy also contains the term_id, but in this table it is linked with another field, the term_taxonomy_id, and also contains some other details.
The third table, wp_term_relationships, contains just three fields: object_id, term_taxonomy_id, and term_order. This is the file in which you can import data to link your posts with categories.
In my case, I export all the posts from a Joomla site and imported them to a new WordPress 2.7 site using phpMyAdmin. I then created all the categories manually, but if you have hundreds you could probably import them to the wp_terms table.
I had previously used phpMyAdmin to export the Joomla posts to an Open Office spreadsheet, but CSV would be fine too. I opened the file in Open Office base, and changed all the Joomla category ID#s to the correct new corresponding WordPress category ID#s, and then deleted all the columns except for the post ID # and the category ID #. I saved it as CSV and used phpMyAdmin to import the file into wp_term_relationships using the "CSV using LOAD DATA" option. Bingo, all my posts were now linked to categories. This was low risk for me, as I was importing the stuff into a blank site, so if I screwed up the import, I could just delete the content from the table and try again, but that was not necessary.
Just to reiterate: importing posts and importing category relationships are separate operations, because the category ID is not listed anywhere in the post record. It seems weird at first, but makes sense when you get your head around it.