MySQL 查询在 Navicat 中有效,但在其他地方生成 MySQL 语法错误

标签 mysql sql dreamweaver syntax-error

大家好,感谢您的提前帮助。我很沮丧,因为我正在编写在 NaviCat 中完美运行的相对较长的 sql 查询(至少对于像我这样的 n00b)。然后我将它们导入 Dreamweaver sql 编辑器(我正在设计我的站点),它们返回

>   MySQL Error#: 1064

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 2 

我将发布其中一个查询,希望有人能指出我做错了什么。

 SELECT (SELECT COUNT(GA_Potential.Potential_ID)
FROM GA_Potential
WHERE GA_Potential.Character_ID=14)+  (SELECT COUNT(GA_PurchasedPotential.PurchasedPotential_ID)From GA_PurchasedPotential Where GA_PurchasedPotential.Member_ID=2)+ (SELECT GA_Characters.StartPotential From GA_Characters WHERE GA_Characters.Character_ID =14)+ (SELECT FLOOR(iot_ActingPoints.Acting_Points/10) From iot_ActingPoints WHERE iot_ActingPoints.Member_ID=2)- (SELECT SUM(GA_AttributePoints.Determination_Points) FROM GA_AttributePoints WHERE GA_AttributePoints.Character_ID=14)- (SELECT SUM(GA_AttributePoints.Dexterity_Points) FROM GA_AttributePoints WHERE GA_AttributePoints.Character_ID=14)- (SELECT SUM(GA_AttributePoints.Productivity_Points) FROM GA_AttributePoints WHERE GA_AttributePoints.Character_ID=14)- (SELECT SUM(GA_AttributePoints.Sophistication_Points) FROM GA_AttributePoints WHERE GA_AttributePoints.Character_ID=14)- (SELECT SUM(GA_AttributePoints.Strength_Points) FROM GA_AttributePoints WHERE GA_AttributePoints.Character_ID=14)- (SELECT IFNULL(SUM(GA_CasteAbilitiesForList.Potential_Cost),0) FROM GA_CasteAbilitiesForList,GA_LearnedAblities WHERE GA_CasteAbilitiesForList.Ability_ID=GA_LearnedAblities.Ability_ID AND GA_LearnedAblities.Character_ID=14)- (SELECT IFNULL(SUM(GA_ProfAbilitiesForList.Potential_Cost),0) FROM GA_ProfAbilitiesForList,GA_LearnedAblities WHERE GA_ProfAbilitiesForList.Ability_ID=GA_LearnedAblities.Ability_ID AND GA_LearnedAblities.Character_ID=14) AS TOTAL

这会生成我在 NaviCat 中想要的数字。

编辑:我删除了 NaviCat 自动放入的所有单引号,但我仍然遇到同样的错误。

提前致谢。

-CB

最佳答案

随便说说:也许你需要在所有子选择的周围使用括号,比如

SELECT 
((SELECT COUNT(`GA_Potential`.`Potential_ID`) From`GA_Potential` WHERE`GA_Potential`.`Character_ID`=14)+ 
(SELECT COUNT(`GA_PurchasedPotential`.`PurchasedPotential_ID`)From`GA_PurchasedPotential` Where`GA_PurchasedPotential`.`Member_ID`=2)+
(SELECT `GA_Characters`.`StartPotential` From `GA_Characters` WHERE `GA_Characters`.`Character_ID` =14)+
(SELECT FLOOR(`iot_ActingPoints`.`Acting_Points`/10) From `iot_ActingPoints` WHERE `iot_ActingPoints`.`Member_ID`=2)-
(SELECT SUM(`GA_AttributePoints`.`Determination_Points`) FROM `GA_AttributePoints` WHERE `GA_AttributePoints`.`Character_ID`=14)-
(SELECT SUM(`GA_AttributePoints`.`Dexterity_Points`) FROM `GA_AttributePoints` WHERE `GA_AttributePoints`.`Character_ID`=14)-
(SELECT SUM(`GA_AttributePoints`.`Productivity_Points`) FROM `GA_AttributePoints` WHERE `GA_AttributePoints`.`Character_ID`=14)-
(SELECT SUM(`GA_AttributePoints`.`Sophistication_Points`) FROM `GA_AttributePoints` WHERE `GA_AttributePoints`.`Character_ID`=14)-
(SELECT SUM(`GA_AttributePoints`.`Strength_Points`) FROM `GA_AttributePoints` WHERE `GA_AttributePoints`.`Character_ID`=14)-
(SELECT IFNULL(SUM(`GA_CasteAbilitiesForList`.`Potential_Cost`),0) FROM `GA_CasteAbilitiesForList`,`GA_LearnedAblities` WHERE `GA_CasteAbilitiesForList`.`Ability_ID`=`GA_LearnedAblities`.`Ability_ID` AND `GA_LearnedAblities`.`Character_ID`=14)-
(SELECT IFNULL(SUM(`GA_ProfAbilitiesForList`.`Potential_Cost`),0) FROM `GA_ProfAbilitiesForList`,`GA_LearnedAblities` WHERE `GA_ProfAbilitiesForList`.`Ability_ID`=`GA_LearnedAblities`.`Ability_ID` AND `GA_LearnedAblities`.`Character_ID`=14))
AS total

还有:错误信息真的在near处结束吗?

关于MySQL 查询在 Navicat 中有效,但在其他地方生成 MySQL 语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9659352/

相关文章:

javascript - 代码有效 jsfiddle 不适用于 Dreamweaver

php - 如何使用 Javascript 在下拉列表中显示选项名称

mysql - 从一行返回多个结果

尽管有 LIMIT,MySQL 使用自定义函数的查询非常慢

php - 拉维尔 |在 2 个表中搜索

sql - 在行不存在或条件匹配的地方加入...?

php - 网站管理员`SELECT * FROM `st_sponsors` WHERE 1 LIMIT 0, 30' at line 1

javascript - 预加载网站

javascript - 如何防止 Dreamweaver 运行本地代码?

sql - 如何创建到 SQL Server 的 ODBC 连接?