Reputation: 7424
I have a query as such
SELECT
COUNT(*) AS TotalAmount
FROM
CurrentApplications
WHERE
CurrentApplications.resp_id IN (1)
AND FinalOutcome_date BETWEEN '2013-04-01 00:00:00' AND '2013-04-30 23:59:59'
AND (FinalOutcome >= 1 AND FinalOutcome <= 2)
AND (FIND_IN_SET(14, app_category)
OR FIND_IN_SET(15, app_category)
OR FIND_IN_SET(26, app_category))
It returns the value of 10 within MySQL Workbench.
Now I'm retriving the query as such:
insideResultsSet = insideStatement
.executeQuery("SELECT COUNT(*) AS TotalAmount FROM CurrentApplications WHERE CurrentApplications.resp_id IN(1) AND FinalOutcome_date BETWEEN '2013-04-01 00:00:00' AND '2013-04-30 23:59:59' AND (FinalOutcome >=1 AND FinalOutcome <= 2) AND( FIND_IN_SET(14, app_category) OR FIND_IN_SET(15, app_category) OR FIND_IN_SET(26, app_category)) ");
while (insideResultsSet.next())
{
mResultValues.put((String)(Reflection("Subdivision_of_land_" + RANGE_NAMES[EachMap.getKey()])),
insideResultsSet.getDouble("TotalAmount"));
Fn.Out(insideResultsSet.getDouble("TotalAmount"));
Fn.Out_Stop("SELECT COUNT(*) AS TotalAmount "
+ mCurrentApplications
+ " WHERE CurrentApplications.resp_id " + mResp_authority + " " + "AND "
+ FIELD_FinalOutcome_date + " " + EachMap.getValue() + "AND (" + FIELD_FinalOutcome
+ " >=1 AND " + FIELD_FinalOutcome + " <= " + FIELD_FinalOutComeORRAHighNumber + ") "
+ getCommaSeachSQL_AppCategory_Multi(new int[]{14,15,26}));
}
The Fn.Out_Stop query is working 100% but the result is not even valid when I output the result directly.
The result is 0 and the object type is null. Can anyone explain what's going on here? Strange error for me as this has worked fine for over 400 other queries..
Upvotes: 0
Views: 87
Reputation: 53689
The column name is probably not "TotalAmount"
. Either try using indexed getters like getLong(1)
or put double quotes around the column name in the query to force case:
"SELECT COUNT(*) AS \"TotalAmount\" ... "
Without quoting the column name in the query the database is free to change the case.
Upvotes: 1