Are you getting an sql syntax error or a php syntax error?
You're trying to select the rows from subscribethread for only one user so you really only need to check the usergroupid and either do the query or not. If you don't have the usergroupid for that user available then you do save one query by combining it like that, but since this is for something that is executed rarely compared to everything going on on the forum, it might be a better idea to do two separate queries and have the code be less complicated.
Having said all that, the way you have it is doing a join to the UPDATE query, but the WHERE goes with the select, so it will probably tell you that there's no column named 'usergroupid'. Maybe you should do this instead:
Code:
INSERT INTO " .TABLE_PREFIX. "unsub_subscribethread AS unsub_subscribethread
SELECT NULL,
userid,
threadid,
emailupdate,
folderid,
canview
FROM " .TABLE_PREFIX. "subscribethread
LEFT JOIN " .TABLE_PREFIX. "user AS user ON (user.userid = unsub_subscribethread.userid)
WHERE userid = '$id'
AND emailupdate IN (1, 2, 3)
AND usergroupid NOT IN (5, 6, 7)