If they're available to you, I'd use a stored procedure if you want a single
query ...

CREATE PROCEDURE sp_hit @id int AS
        UPDATE sitecount
        SET hits = hits + 1
        WHERE id = @id;

        SELECT hits FROM sitecount
        WHERE id = @id;
GO

<cfquery name="currentHits">
        EXEC sp_hit @id = #idpassed#
</cfquery>

hth

s. isaac dealey                954-776-0046

new epoch                      http://www.turnkey.to

lead architect, tapestry cms   http://products.turnkey.to

certified advanced coldfusion 5 developer
http://www.macromedia.com/v1/handlers/index.cfm?ID=21816



> I have a quick SQL question:

> I need to keep a running count of the time a specific location is
> requested
> and I could do it with 2 queries ie.

> <cfquery name="currentHits">
> select hits
> from sitecount
> where id = #idpassed#
> </cfquery>

> <cfset new_hit = currentHits.hits + 1>

> <cfquery name="update_currentHits">
> update sitecount
> set hits = #new_hit#
> where id = #idpassed#
> </cfquery>


> But I was wondering if you could do it in a single statment since it is an
> incremental variable.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm

Reply via email to