Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query Weirdness

Status
Not open for further replies.

Sarky78

Programmer
Oct 19, 2000
878
GB
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=&quot;test&quot; ame=&quot;getMaxQuestion&quot;>
SELECT Max(CompetitionID) as maxComp
FROM tblCompetition
WHERE Hotel = #variables.hotel#
</cfquery>

<cfquery datasource=&quot;test&quot; name=&quot;getQuestion&quot;>
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 ??
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top