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

原文地址:https://www.cnblogs.com/zejin2008/p/9722912.html

时间: 2024-10-16 20:40:45

MySQL: Set user variable from result of query的相关文章

MySQL:unknown variable 'master-host=masterIP' [ERROR] Aborting

<span style="font-size:18px;">120401 15:45:44 [ERROR] C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqld: unknown variable 'master-host=192.168.8.111' 120401 15:45:44 [ERROR] Aborting --------解决方式-------------------- Mysql版本号从5.1.7以后開始就不支持

MySQL:unknown variable &#39;master-host=masterIP&#39; [ERROR] Aborting

<span style="font-size:18px;">120401 15:45:44 [ERROR] C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqld: unknown variable 'master-host=192.168.8.111' 120401 15:45:44 [ERROR] Aborting --------解决方案-------------------- Mysql版本从5.1.7以后开始就不支持&

Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Result consisted of more than

1.错误描述 at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125) at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66) at org.apache.shiro.web.servlet.AbstractShiroFilter.executeCha

mysql:unknown variable &#39;default-character-set=utf8&#39;

1.修改my.cnf后,执行 service mysql restart 重启数据库失败 service mysql restart Shutting down MySQL.. SUCCESS! Starting MySQL... ERROR! The server quit without updating PID file (/usr/local/mysql/data/VM_0_12_centos.pid) 2.查看日志: cat VM_0_12_centos.err |grep ERROR

mysql: [ERROR] unknown variable &#39;datadir=/var/lib/mysql&#39;问题

环境: Centos7,mysql 5.7 问题: 在使用命令"mysql -u root -p"连接mysql时,报:"mysql: [ERROR] unknown variable 'datadir=/var/lib/mysql'". 分析: 网上出现这个问题很少,通过类似问题,发现这个问题跟"my.cnf"配置有关,该配置文件在"/etc/my.cnf". 在使用mysql命令连接时,需要获得[client]参数,而da

Mysql报错:1172 - Result consisted of more than one row

执行mysql函数时报错:1172 - Result consisted of more than one row 函数语句中select into语句中WHERE account = userName查出的结果出现2条相同的记录才报出这个错误 SELECT id,last_stamp,token INTO userID,lastStamp2,tokenStr2 FROM game_user WHERE account = userName;

com.mysql.jdbc.PacketTooBigException: Packet for query is too large (1169 &gt; 1024)

### Cause: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (1169 > 1024). You can change this value on the server by setting the max_allowed_packet' variable. ; SQL []; Packet for query is too large (1169 > 1024). You can change

Mysql slow query log

一.概念部分:  顾名思义,慢查询日志中记录的是执行时间较长的query,也就是我们常说的slow query,通过设--log-slow-queries[=file_name]来打开该功能并设置记录位置和文件名,默认文件名为hostname-slow.log,默认目录也是数据目录.     慢查询日志采用的是简单的文本格式,可以通过各种文本编辑器查看其中的内容.其中记录了语句执行的时刻,执行所消耗的时间,执行用户,连接主机等相关信息.MySQL还提供了专门用来分析满查询日志的工具程序mysql

MySQL5中大数据错误:Packet for query is too large (****** &gt; ******). You can change this value on the server by setting the max_allowed_packet&#39; variable.;

使用的MySQL数据库版本:5.5 插入或更新字段有大数据时(大于1M),会出现如下错误: ### Cause: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (1132484 > 1048576). You can change this value on the server by setting the max_allowed_packet' variable. ; SQL []; Packet fo