mysql 触发器
创建一个触发器
DELIMITER $$
CREATE TRIGGER `test_lejiasr`.`create_sid` BEFORE INSERT
ON `test_lejiasr`.`device_fids`
FOR EACH ROW
BEGIN
IF(new.sid IS NULL) THEN
SET new.sid = CONCAT( 'SID:', ( SUBSTRING_INDEX( new.fid, 'SSH', 1 ) ), ( SELECT FLOOR( 10 + ( RAND( ) * 89 ) ) ) ) ;
END IF;
END$$
DELIMITER ;