我已经尝试了所有可能对语法产生影响的内容,但没有任何效果。我想运行此脚本以向名为pm_Permissions的表添加条目。但是,当我再次运行它并且该条目已经存在时,我不希望它再次添加。
IF NOT EXISTS (SELECT 1 FROM pm_Permissions WHERE permission_tag = 'dbcorrectstructure')
BEGIN
LOCK TABLES `pm_Permissions` WRITE;
/*!40000 ALTER TABLE `pm_Permissions` DISABLE KEYS */;
INSERT INTO `pm_Permissions` VALUES (NULL,'dbCorrectStructure', 'Makes sure all the correct tables, columns and entries exist','dbcorrectstructure','$sourcedir/administration.lib.php','dbCorrectStructure','Administration',0);
/*!40000 ALTER TABLE `pm_Permissions` ENABLE KEYS */;
UNLOCK TABLES;
END
提前致谢。
答案 0 :(得分:0)
(SELECT 1 FROM pm_Permissions WHERE permission_tag = 'dbcorrectstructure')
此处为permission_tag = 'dbcorrectstructure'
,但在您插入时'dbCorrectStructure'
...
这是正确的吗?我认为你应该匹配案例..
您应该像(SELECT 1 FROM pm_Permissions WHERE permission_tag = 'dbCorrectStructure')