存储过程代码:
BEGIN IF sex_id =0 THEN SELECT COUNT(*) FROM mybatis.p_user WHERE p_user.sex=‘女‘ INTO sex_count; ELSE SELECT COUNT(*) FROM mybatis.p_user WHERE p_user.sex=‘男‘ INTO sex_count; END IF; END
条件:
IN `sex_id` int,OUT `sex_count` int
执行:
SET @sex_count=0; CALL mybatis.user_count(1,@sex_count); SELECT @sex_count;//可设置别名 SELECT @sex_count count;
结果:
时间: 2024-10-12 14:45:54