Skip to main content
Inspiring
April 25, 2008
Question

Total Noob wanting some help

  • April 25, 2008
  • 2 replies
  • 307 views
Hi guys I just got new job and they use CF over here. My first small project is
thowing me for a loop just because I've never really worked databases before.
I'm looking for some starting help. We have this intranet site that everyone
here uses to place orders and stuff, they all use bunches of databases. And
what my boss is wanting me to do is find a way to put a count of all the items
in a database that match a certian criteria on the main page. So what I need is
a way to count database items. Help would be helpful. Like I said I'm a total
n00b and forgive me if you can't make heads or tails of this. I'd be glad to
explain more in depth for help. Thanks guys

Kevin

This topic has been closed for replies.

2 replies

Inspiring
April 25, 2008
Since you've never worked with databases before, I've heard good things about the book, Teach Yourself SQL in 10 Minutes by Ben Forta.
Inspiring
April 25, 2008
What do you need the database count or a specific based on a query?

Both solutions here: just copy, change the ODBC name and ready to go!

<!---//A simple query with a simple cfoutput of that query with recordcount START--->

<cfset request.app.dsn = 'myodbc'>
<cfquery name="mycount" datasource="#request.app.dsn#">
select * from mytable where mycolumn like 'this'
</cfquery>

<cfif mycount.recordcount GT 0>

Records inside mycount query: <cfoutput>#mycount.RecordCount#</cfoutput>

Now the records:
<cfoutput query="mycount"><p>#name# #lastname# #etc#</p></cfoutput>

<cfelse>
No records for thsi query!
</cfif>

<!---//END--->

Best regards,

Cesar Mejia