大家好,谢谢您的帮助。我感到沮丧是因为我正在编写相对较长的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

最佳答案

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

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结尾吗?

10-07 17:57