MySQL: Set user variable from result of query

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MySQL: Set user variable from result of query相关的知识,希望对你有一定的参考价值。

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

以上是关于MySQL: Set user variable from result of query的主要内容,如果未能解决你的问题,请参考以下文章

Mysql:一个查询中的“SET @Variable = 0”[Java]

watchpoint set variable

mysql:unknown variable 'default-character-set=utf8'

mysql: [ERROR] unknown variable 'default-character-SET=utf8'.

mysql报错:/usr/sbin/mysqld:unknown variable 'default-character-set=utf8'

如何选择表名为Variable的MySQL