mysql 触发器的新手问题.
表tab3 如果ID大于5,自动改为5,
Create table tab3(id int not null);
Create trigger inser_update_a
Before insert or update on tab3
FOR each ROW
AS BEGIN
IF tab3.id >5
then tab3.id= 5
end if
end ;
上面有错吗, 我运行不出来,报错:
Error Code : 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 'or update on tab3
FOR each ROW
AS BEGIN
IF tab3.id >5
then tab3.id= 5
end if
e' at line 2
请问各位是怎么回事呢..
Before insert or update on tab3
MySQL不支持这种语法,只能分开写。写两个触发器分别是
Create trigger inser_update_a_1 before insert ....
Create trigger inser_update_a_2 before update ....
MySQL官方文档 http://dev.mysql.com/doc/refman/5.1/zh/index.html
ACMAIN_CHM:
你好,
我把update 删了,运行:
Create trigger inser_update_a
Before insert on tab3
FOR each ROW
AS BEGIN
IF tab3.id >5
then tab3.id= 5
end if
end ;
语法上应该没错,我是看了数据库系统概论里面的一个例子,再用本地的做下实验,但是还是报错:
Error Code : 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 'AS BEGIN
IF tab3.id >5
then tab3.id= 5
end i
相关问答:
有个winform程序,使用c#+mysql,需要在一个窗体设置mysql自动删除功能,包括自动删除多少天之前的数据以及是否开启自动删除功能,我程序退出后,还怎么控制Mysql自己删除啊?是不是要用mysql的event来实现?c#可以调用mysq ......
原帖请看
http://topic.csdn.net/u/20100115/09/98c6ac75-d6fe-4b6c-90dc-336a738a0c0f.html?14601
总结下就是
apache php mysql 我全部都用的是gb2312,有什么办法可以不用每次mysql_query('SET character_set_r ......
各位兄弟请教 下,在mysql中能不能实现这样一个功能,
一个字段A是储存一大段文字内容的,是英文,能不能通过MYSQL的查询之类的功能,来获得这个字段中 出现频率最高的十个单词,并将这十个单词做为新的字段储存
a ......
请问
添加新数据源->数据库->添加连接
这个界面下,数据源选择:Microsoft SQL Server (SqlClient);
服务器名:
应该写什么呢?
有谁知道?多谢各位!!
你到底是要连mysql还是mssql?
引用
请问
......
String sqlCount="select count(*) from usertable where username='"+
userName+"'";这句话 什么意思啊!
这句话输出出来就是
select count(*) from usertable where username='你的变量 ......