set @user = 123456;
set @group = (select GROUP from USER where User = @user);
select * from USER where GROUP = @group;
SET @user := 123456;
SELECT @group := `group` FROM user WHERE user = @user;
SELECT * FROM user WHERE `group` = @group;
SET @user := 123456;
SELECT `group` FROM user LIMIT 1 INTO @group;
SELECT * FROM user WHERE `group` = @group;
refer:https://stackoverflow.com/questions/3888735/mysql-set-user-variable-from-result-of-query