【发布时间】:2017-01-11 15:02:39
【问题描述】:
我在我的 java 程序中使用嵌入式 hsql 数据库。 我想写一个这样的hsql语句:
statement.executeQuery("SELECT sum(Points) FROM Table");
一开始我试过这个:
String column = "Points";
statement.executeQuery("SELECT sum(\""+column+"\") FROM \""+table+"\"");
java.sql.SQLException: Column not found: Points
下一个:
statement.executeQuery("SELECT sum(POINTS) FROM \""+table+"\"");
java.sql.SQLSyntaxErrorException: user lacks privilege or object not found: POINTS
下一次尝试,不应该只为你工作:-)
statement.executeQuery("SELECT sum(\'"+column+"\') FROM \""+table+"\"");
java.sql.SQLSyntaxErrorException: incompatible data type in operation
如果我试试这个:
statement.executeQuery("SELECT \""+column+"\" FROM \""+table+"\"");
完美运行
只是为了告诉你我的列存在于我的表中。
此声明:
SELECT sum("Points") as test FROM "MyTable"
在 SQuirrel 客户端版本 3.7 中运行
知道我的问题吗?
【问题讨论】: