select sum() from tb1 into @a ,这种语句为何报错呢?但是加上 where 就不报错。
select sum(f2)
from tb1
where 1=1 -- 为何这里没有这一句,就会报错呢?
into @a;
select @a;
drop table if exists tb1;CREATE TABLE `tb1` (
`f1` int(11) DEFAULT NULL,
`f2` decimal(18,2) DEFAULT NULL
) ;-- go
insert into tb1 values(1,89.67),(2,67.34),(3,88.12);select *
from tb1;
select sum(f2)
from tb1
where 1=1 -- 为何这里没有这一句,就会报错呢?
into @a;
select @a;
select sum(f2)
from tb1
where 1=1 -- 为何这里没有这一句,就会报错呢?
into @a;
select @a;
drop table if exists tb1;CREATE TABLE `tb1` (
`f1` int(11) DEFAULT NULL,
`f2` decimal(18,2) DEFAULT NULL
) ;-- go
insert into tb1 values(1,89.67),(2,67.34),(3,88.12);select *
from tb1;
select sum(f2)
from tb1
where 1=1 -- 为何这里没有这一句,就会报错呢?
into @a;
select @a;
解决方案 »
- 关于mysql编码,utf8为什么会这么浪费空间
- id parentid name 如何实现无限类别???
- 一个难度一般的问题,帮忙解决
- 请教:关于MYSQL 一条删除数据库命令
- mysql中查询数据问题!!!
- mysql连接数据库出现Communication failure during handshake. Is there a server running on 127.0.0.1:3306?
- 对于mysql的连接问题的总结(-)
- 请问MySQL 4.0 是否支持存储过程和视图?
- 关于联合主键的一些疑问
- MySql经常无故自动停止服务,求帮助
- PG数据库表分区的实现疑问。
- mysql中的存储过程与函数有区别吗?
select sum() from tb1 into @a 这种格式
你太有意思了,sum()是简写呀,我偷懒,我以为大家会明白的。
我总不至于连 sum() 必须有参数也不知道呀。你的回复,我刚明白是什么意思