You can just remove the category_id = <number> filter altogether, so the query would look something like:
SELECT
cu.*,
ue.email
FROM category_users cu
JOIN user_emails ue
ON ue.user_id = cu.user_id
WHERE ue.primary = true
The Data Explorer will display category names for you, but they won’t show up when you export the results. If that’s a problem for you, you can explicitly add the category name as a column, something like this:
SELECT
c.name,
cu.*,
ue.email
FROM category_users cu
JOIN user_emails ue
ON ue.user_id = cu.user_id
JOIN categories c
ON cu.category_id = c.id
WHERE ue.primary = true
ORDER BY c.name