CREATE TABLE `entry_group` ( `entry` varchar(255) NOT NULL, `gid` tinyint(4) NOT NULL, `name` varchar(255) DEFAULT NULL, `info` varchar(255) DEFAULT NULL, KEY `index_entry` (`entry`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; INSERT INTO `entry_group` VALUES (‘web_qq‘, ‘1‘, ‘qq空间‘, ‘qq空间‘); INSERT INTO `entry_group` VALUES (‘web_joker‘, ‘2‘, ‘官网‘, ‘官网‘); INSERT INTO `entry_group` VALUES (‘mobile_qq‘, ‘3‘, ‘应用宝‘, ‘应用宝qq‘); INSERT INTO `entry_group` VALUES (‘mobile_wx‘, ‘3‘, ‘应用宝‘, ‘应用宝微信‘); ALTER TABLE `user_info` ADD COLUMN `egid` TINYINT DEFAULT 0 NULL AFTER `entry`; UPDATE user_info u INNER JOIN entry_group e ON u.entry = e.entry SET u.egid = e.gid ; BEGIN SET @pf = new.entry; SET @aa = (SELECT gid FROM entry_group WHERE entry = @pf); SET new.egid = @aa; END
时间: 2024-10-21 17:44:53