mysql> create procedure productpricing() BEGIN select Avg(prod_price) as priceaverage from products; END;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'END' at line 1
看mysql必知必会这书,里面的例句执行失败
mysql版本:Server version: 5.1.41-3ubuntu12.10 (Ubuntu)mysql> show columns from products;
+------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+-------+
| prod_id | char(10) | NO | PRI | NULL | |
| vend_id | int(11) | NO | MUL | NULL | |
| prod_name | char(255) | NO | | NULL | |
| prod_price | decimal(8,2) | NO | | NULL | |
| prod_desc | text | YES | | NULL | |
+------------+--------------+------+-----+---------+-------+
5 rows in set (0.00 sec)
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'END' at line 1
看mysql必知必会这书,里面的例句执行失败
mysql版本:Server version: 5.1.41-3ubuntu12.10 (Ubuntu)mysql> show columns from products;
+------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+-------+
| prod_id | char(10) | NO | PRI | NULL | |
| vend_id | int(11) | NO | MUL | NULL | |
| prod_name | char(255) | NO | | NULL | |
| prod_price | decimal(8,2) | NO | | NULL | |
| prod_desc | text | YES | | NULL | |
+------------+--------------+------+-----+---------+-------+
5 rows in set (0.00 sec)
解决方案 »
- mysql 备份还原
- 请问为什么MySQL导出的sql里的表格先后顺序不受外键限制?
- exists(select 1 from ...)怎么理解
- mysql有没有什么设置能 登记 错误的sql?
- mysql支持中文问题
- 我想把mysql里的数据搬到另一台服务器上,大家看看这样是不是就可以
- mysql的问题
- 关于MYSQL查询的一个问题,求各位帮忙~~~~~
- 通过mysql administrator v1.1.0 rc版本怎么把现有的*.sql数据库表倒入系统??急。在线等!
- 关于数据库字段的长度的问题
- 从数据库读出的数据,只显示最后一条,且把其他的都覆盖了。
- mysql insert语句 怎么存储一维数组变量
create procedure productpricing()
BEGIN select Avg(prod_price) as priceaverage from products;
END$$
delimiter;
from products;
Query OK, 0 rows affected (0.00 sec)OR
mysql> DELIMITER $$
mysql> CREATE PROCEDURE productpricing()
-> BEGIN
-> SELECT AVG(prod_price) AS priceaverage FROM products;
-> END$$
Query OK, 0 rows affected (0.00 sec)
否则的话遇到;就会自动结束mysql> DELIMITER $$
mysql> CREATE PROCEDURE productpricing()
-> BEGIN
-> SELECT AVG(prod_price) AS priceaverage FROM products;
-> END$$
mysql> DELIMITER ;