关闭

自己遇到的Mysql错误(初学)

标签: mysql
347人阅读 评论(0) 收藏 举报
分类:

1.复制时需要把->去掉 不然会报错

mysql> CREATE PROCEDURE s_insert(IN id int,IN name VARCHAR(20),IN count int)
   BEGIN
    SET @id=id;
    SET @name =name;
    SET @count=count;
    SET @insertSql =CONCAT('insert into store values(?,?,?)');
    PREPARE stmtinsert FROM @insertSql;
    EXECUTE stmtinsert USING @id,@name,@count;
    DEALLOCATE PREPARE stmtinsert;
    END;
Query OK, 0 rows affected

mysql> CREATE PROCEDURE s_insert(IN id int,IN name VARCHAR(20),IN count int)
   BEGIN
    ->SET @id=id;
    ->SET @name =name;
    ->SET @count=count;
    ->SET @insertSql =CONCAT('insert into store values(?,?,?)');
    ->PREPARE stmtinsert FROM @insertSql;
    ->EXECUTE stmtinsert USING @id,@name,@count;
    ->DEALLOCATE PREPARE stmtinsert;
    ->END;
1064 - 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 '->SET @id=id;
    ->SET @name =name;
    ->SET @count=count;
    ->SET @inser' at line 3

2.

表名,字段名,存储过程等 打‘引号’不是英文输入下的‘’
英文下的单引号是用来包含字符串或者字符的
会报错 不知道是怎么打出来的`

DROP PROCEDURE IF EXISTS `P_GET_CLASS_NAME`;
 store | CREATE TABLE `store` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(20) NOT NULL,
  `count` int(11) NOT NULL DEFAULT '1',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8 |
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:18731次
    • 积分:1115
    • 等级:
    • 排名:千里之外
    • 原创:75篇
    • 转载:35篇
    • 译文:13篇
    • 评论:0条
    最新评论