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

时间:2012-03-11 22:07:07

标签: mysql sql dreamweaver syntax-error

大家好,感谢您的帮助。我很沮丧,因为我正在编写相对较长的SQL查询(至少对于像我这样的n00b),它在NaviCat中完美运行。然后我将它们导入到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

2 个答案:

答案 0 :(得分:0)

只是一个时髦的镜头:也许你需要在所有子选择周围使用括号,比如

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

结束

答案 1 :(得分:0)

有同样的问题 - 将此留给其他遇到此问题的人:

Dreamweaver不喜欢SQL中的多个SELECT语句。我能够重新处理我的查询,不需要多个SELECT语句,错误就消失了。

作为补充说明,我认为这是括号,但它们似乎与其他功能一起正常工作。