I would typically alias the column so that you don't have to guess what kind
of default name the backend will assign. Then you can simply reference that
column just like you would any other query column. Keep in mind that a
count(*) by itself will always output exactly one row, even if the count is
zero.
<cfquery name="works" datasource="project" dbtype="ODBC">
SELECT count(*) as ct FROM job
where cyv_id = '#FORM.cyv_id#' and job_close is null
</cfquery>
<cfoutput>
Number of null records in JOB table: #works.ct#
</cfoutput>
-Chris Gilbert, Fodors.com
-----Original Message-----
From: Redd Liao [mailto:[EMAIL PROTECTED]]
Sent: Friday, June 15, 2001 12:36 PM
To: CF-Server
Subject: RE: What's wrong? (urgent)
if i use count(*), how can i output the number?
thanks
>From: "Gilbert, Chris" <[EMAIL PROTECTED]>
>Reply-To: [EMAIL PROTECTED]
>To: CF-Server <[EMAIL PROTECTED]>
>Subject: RE: What's wrong? (urgent)
>Date: Fri, 15 Jun 2001 12:03:41 -0400
>
>Actually, now that I think about it for more than 5 seconds (*grin*) if all
>you really want is the recordcount, you should just let the Database do the
>counting rather than making it fetch all the rows, send them to CF, and
>then
>making CF count the rows. If you *really* don't need the data, then try
>this:
>
>SELECT count(*) FROM job
>where cyv_id = '#FORM.cyv_id#' and job_close is null
>
>-Chris Gilbert, Fodors.com
>
>-----Original Message-----
>From: Redd Liao [mailto:[EMAIL PROTECTED]]
>Sent: Friday, June 15, 2001 12:05 PM
>To: CF-Server
>Subject: What's wrong? (urgent)
>
>
>I use MS SQL and CF 4.5.
>
><cfquery name="works" datasource="project" dbtype="ODBC">
>SELECT * FROM job
>where cyv_id = '#FORM.cyv_id#' and job_close = ''
></cfquery>
>
>I wanna get works.recordcount in which job_close is null,
>but i always get 0. Is there anything wrong in cfquery?
>Thanks.
>
>R
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
------------------------------------------------------------------------------
To unsubscribe, send a message to [EMAIL PROTECTED] with
'unsubscribe' in the body or visit the list page at www.houseoffusion.com