Hey everyone, i just started getting into coldfusion and i would really appreciate some help, this thing has been buggin me for ages! Basically, i would like a cfquery to find the lowest number (autonumber) in my table(admin_tbl) and display it so i can later do some cfif function to it. Ive tried this amongst other things so far: <cfquery name="adminnum" datasource="cso6"> SELECT min(user_id) FROM admin_tbl </cfquery> <cfoutput query="adminnum"> #user_id# </cfoutput> Cheers for checking this out! Much appreciated!
Try this: <cfquery name="adminnum" datasource="cso6"> SELECT min(user_id) As MinUserId FROM admin_tbl </cfquery> <cfoutput>#adminnum.MinUserId#</cfoutput> Code (markup):
He's right. When you use an aggregate such as min, max, count, sum, you need to give it a name by typing min(aaaa) as xyz. Then coldfusion will be able to look it up using xyz as the variable name