You are attempting to use the table alias a
inside of your subquery which is causing the error. You should be able to write the query the following way:
SELECT a.group_id
FROM message_private a
INNER JOIN message_group b
ON b.group_id = a.group_id
WHERE b.profile_id = 's';
If you need a subquery, then the syntax would be:
SELECT a.group_id
FROM message_private a
INNER JOIN
(
SELECT group_id,profile_id
FROM message_group
WHERE profile_id = 's'
) b
ON b.group_id = a.group_id