正在弄mysql ,但一个问题困扰到我.
我想从表里面查询出数据. 将数据,比如count(*)这个值赋给存储过程的变量,但好像不行,不知道是这样写吗,还是其他什么方法?.
select set peoCountAll = count(*) from user where user_from = userFrom and user_add_date > t1 and user_add_date < t2 ;
问题补充:还有该如何禁止select 语句的结果集显示呢?
该存储过程
drop PROCEDURE total;DELIMITER $$CREATE
/*[DEFINER = { user | CURRENT_USER }]*/
PROCEDURE total( in t1 DATETIME ,in t2 DATETIME ,in userFrom int)
/*LANGUAGE SQL
| [NOT] DETERMINISTIC
| { CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA }
| SQL SECURITY { DEFINER | INVOKER }
| COMMENT 'string'*/
BEGIN
declare peoCountAll varchar(10);/*所有激活人群*/
declare peoCountBack varchar(20);/*继续玩游戏人群*/
declare peoRecharg float;/*总共充值金额*/
select set peoCountAll = count(*) from user where user_from = userFrom and user_add_date > t1 and user_add_date < t2 ;
/*SELECT peoCountAll as '总人数';*/
/*select count(*) from user where user_from = userFrom and user_user_last_logon;*/
END$$DELIMITER ;
我想从表里面查询出数据. 将数据,比如count(*)这个值赋给存储过程的变量,但好像不行,不知道是这样写吗,还是其他什么方法?.
select set peoCountAll = count(*) from user where user_from = userFrom and user_add_date > t1 and user_add_date < t2 ;
问题补充:还有该如何禁止select 语句的结果集显示呢?
该存储过程
drop PROCEDURE total;DELIMITER $$CREATE
/*[DEFINER = { user | CURRENT_USER }]*/
PROCEDURE total( in t1 DATETIME ,in t2 DATETIME ,in userFrom int)
/*LANGUAGE SQL
| [NOT] DETERMINISTIC
| { CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA }
| SQL SECURITY { DEFINER | INVOKER }
| COMMENT 'string'*/
BEGIN
declare peoCountAll varchar(10);/*所有激活人群*/
declare peoCountBack varchar(20);/*继续玩游戏人群*/
declare peoRecharg float;/*总共充值金额*/
select set peoCountAll = count(*) from user where user_from = userFrom and user_add_date > t1 and user_add_date < t2 ;
/*SELECT peoCountAll as '总人数';*/
/*select count(*) from user where user_from = userFrom and user_user_last_logon;*/
END$$DELIMITER ;
SELECT @peoCountAll as '总人数'