create table login(
idlogin bigint unsigned not null auto_increment primary key,
username varchar(50) not null unique,
nickname varchar(50) not null,
enroltime timestamp not null default current_timestamp,
lasttime timestamp not null,
failCount int unsigned not null default 0,
bfreeze bool not null default false);create trigger trigger_bi_lt before insert on login
for each row
if new.lasttime is null then set new.lasttime = current_timestamp;  -----1在句1处错误,试过set new.lasttime = current_timestamp()和set new.lasttime = now()。都是一样的错误。错误信息为: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 3各位帮忙看看吧

解决方案 »

  1.   

    DELIMITER $$
    CREATE TRIGGER trigger_bi_lt BEFORE INSERT ON login
    FOR EACH ROW
    BEGIN
    IF new.lasttime IS NULL THEN 
    SET new.lasttime=CURRENT_TIMESTAMP; 
    END IF;
    END $$
      

  2.   

    建表语句:lasttime timestamp not null,
    not null 拿掉    
    已经定义不为空了怎么还会出现 if new.lasttime is null
      

  3.   

    create trigger trigger_bi_lt before insert on login
    for each row
    if new.lasttime is null then set new.lasttime = current_timestamp; end if;