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
原文地址:https://www.cnblogs.com/zejin2008/p/9722912.html
时间: 2024-10-16 20:40:45