Foreach term_data.tid as$tid{INSERT INTO tid_uid (tid, uid) VALUES $tid, (SELECT uid FROM “node” WHERE nid = the nid from term_node on the same line where tid = $tid(LIMIT 1)
SELECT DISTINCT(node.nid), comments.timestamp AS comments_timestamp_timestamp, node.title AS node_title, node.changed AS node_changed FROM node node LEFT JOIN comments comments ON node.nid = comments.