表A player 主要字段 [playerid] [username]
表B playerbattle 主要字段 [playerid] [level]
表C chongzhi 主要字段 [username] [golden]表A 和表B 通过[playid] 进行关联
需求是 如果 playerbattle 的[level] 变化为100 则通过字段[playid]联合player表 查出 [username],然后把 [username] 插入到 chongzhi 表中!下面是我自己写的。但是有个问题是。。我想只有level=100(不管其他字段怎么变)的时候就插入记录。现在的情况是 level=100.其他字段变了。也插入记录了。大家帮我看下 问题怎么解决!!!BEGIN
set @sql = (select userName from player WHERE playerId = new.playerId and new.level = 100);
if !@sql then
begin
insert into chongzhi (userName,chrName,costmoney,golden,chongzhichuli,datatime) values (@sql,@sql,'5000000','5000000','0',datatime = now());
end;
end if;
ENDsqlinsert
表B playerbattle 主要字段 [playerid] [level]
表C chongzhi 主要字段 [username] [golden]表A 和表B 通过[playid] 进行关联
需求是 如果 playerbattle 的[level] 变化为100 则通过字段[playid]联合player表 查出 [username],然后把 [username] 插入到 chongzhi 表中!下面是我自己写的。但是有个问题是。。我想只有level=100(不管其他字段怎么变)的时候就插入记录。现在的情况是 level=100.其他字段变了。也插入记录了。大家帮我看下 问题怎么解决!!!BEGIN
set @sql = (select userName from player WHERE playerId = new.playerId and new.level = 100);
if !@sql then
begin
insert into chongzhi (userName,chrName,costmoney,golden,chongzhichuli,datatime) values (@sql,@sql,'5000000','5000000','0',datatime = now());
end;
end if;
ENDsqlinsert
解决方案 »
- 求助mysql读取一小时之前数据问题,谢谢
- 在存储过程中记录把错误信息记录到自定义表中
- mysql怎么取得当月所有日期、星期
- ERROR 126 (HY000): Incorrect key file for table '/tmp/#sql_6f81_0.MYI'; try to r
- MySQL创建表出错,急!
- mysql如何传递in条件的参数
- infinidb第一帖
- 为什么我的数据库显示不了汉字呀
- 为什么where中出现了is null还能使用索引?
- MYSQL中一个表有8000W(8千万级)的数据,打算对一个URL字段去重,有什么快的方法,高手进!
- ERROR 1048 (23000): Column 'col' cannot be null 问题
- 求一句mysql sql语句
....
OR
if IFNULL(@sql,1)<>1 THEN
....
到底是否插入?举例说明
你是怎样插入记录的
select userName from player WHERE playerId = new.playerId and new.level = 100
and new.level<>old.level
就差了这一句!! and new.level<>old.level 3q!!!