I'm trying to use a database to keep track of login members' uploaded pictures. Each member has an id (Faculty_ID), then every image they upload has a number assigned to it. The problem I'm running into is that the members who haven't uploaded anything yet end up with an error. <cfquery datasource="faculty" name="Image"> SELECT max(ImageNo) FROM Faculty_Artwork WHERE Faculty_ID = #fid# </cfquery> <cfif Image.RecordCount EQ "0"> <cfset imageno=1> <cfelse> <cfset number=Image.expr1000> <cfset imageno= #number#+1> </cfif> I thought Image.RecordCount would be 0 if there's no files in the database with that Faculty_ID, but it ends up set to 1, thus causing coldfusion to use the wrong part of the if. Any suggestions? I'm very new to coldfusion.
Your recordcount WILL be 1. That is because it will always return 1 record, just because of the way you wrote your query. Alias your max(ImageNo) in your current query, then do the <cfif on imageNo.aliasname is 0>.
I see what you mean: I'm getting a RecordCount of one (which apparently is whatever number is #fid# under the name ID) and a ColumnList of EXPR1000. What exactly in the query's statment is doing that? Also, what do you mean by alias and how do you do that? (I apologize for asking what is likely a noob question, I'm learning all this on the fly.)
I think what he means is to use this: SELECT max(ImageNo) AS aliasname instead of this: SELECT max(ImageNo) and then <cfif on image.aliasname is 0>.