I have got a simple query that I have used for a while, to get the newest record from a table. I have added a where clause to the query so that I only get the newest record for the category that i want. The problem that I am having is that the query is returning a record when one does not exist. I think that the where clause is being ignored in the first query (getMaxQuestion), and returning incorrect information.
The query looks like this:
<cfquery datasource="test" ame="getMaxQuestion">
SELECT Max(CompetitionID) as maxComp
FROM tblCompetition
WHERE Hotel = #variables.hotel#
</cfquery>
<cfquery datasource="test" name="getQuestion">
SELECT *
FROM tblCompetition
WHERE CompetitionID = #getMaxQuestion.maxComp#
</cfquery>
The query is running through coldfusion connected to a access database via ODBC. The query does what I expect it to do in Access, but not in CF.
Is this the case, can anyone think of a way of getting around this problem ??
The query looks like this:
<cfquery datasource="test" ame="getMaxQuestion">
SELECT Max(CompetitionID) as maxComp
FROM tblCompetition
WHERE Hotel = #variables.hotel#
</cfquery>
<cfquery datasource="test" name="getQuestion">
SELECT *
FROM tblCompetition
WHERE CompetitionID = #getMaxQuestion.maxComp#
</cfquery>
The query is running through coldfusion connected to a access database via ODBC. The query does what I expect it to do in Access, but not in CF.
Is this the case, can anyone think of a way of getting around this problem ??