This query displays users who registered more than 30 days ago and are in group 5:
SELECT U_Username,FROM_UNIXTIME(U_Registered) AS Registered,(UNIX_TIMESTAMP()-U_Registered)/(3600*24) AS "How many days ago",U_Groups
FROM w3t_Users
WHERE ((UNIX_TIMESTAMP()-U_Registered)/(3600*24) > 30)
AND U_Groups LIKE "%-5-%"
This query changes the group memberships of the same users to 3, 7 and 8:
UPDATE w3t_Users
SET U_Groups="-3-7-8-"
WHERE ((UNIX_TIMESTAMP()-U_Registered)/(3600*24) > 30)
AND U_Groups LIKE "%-5-%"
Don't run that UPDATE query unless you're sure that's exactly what you want to do. Usual disclaimer: backup the database first.
Does this answer your question?