MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old October 22nd, 2005, 08:44 AM
Johnie Johnie is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: North Devon - England
Posts: 20 Johnie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 25 m 5 sec
Reputation Power: 0
Using a mySQL result

I'd like to work with a total from a column in a mySQL table.

ie
SELECT SUM(columnname) AS myanswer FROM TableName

It seems to work, but how can I print it out on a page

I've tried

SELECT SUM(columnname) AS myanswer FROM TableName
Response.Write myanswer

which gets no errors but prints nothing either

tried

myanswer = (SELECT SUM(columnname) AS myanswer FROM TableName
)

Reponse.Write myanswer

But not working either

How can I gather up the mySQL results to make use of it, either printing it to the page or using it in an IF statement??

Johnie

Reply With Quote
  #2  
Old October 22nd, 2005, 09:00 AM
Johnie Johnie is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: North Devon - England
Posts: 20 Johnie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 25 m 5 sec
Reputation Power: 0
Sussed it

I know my brain isn't working well today ..

Set RS = adoConn.Execute("SELECT SUM(columnname) AS myvalue FROM TableName")
Response.Write RS.Fields(myvalue)

Reply With Quote
  #3  
Old December 8th, 2005, 08:14 AM
Laban Laban is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Posts: 40 Laban User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 15 m 32 sec
Reputation Power: 4
As assume you are trying to output things in ASP and not PHP. My ASP days are over but I recall this:

<%= myvalue %> (Same as <% Response.Write myvalue %>

Where you like it to be written....in the HTML code on the page. This of course assumes you have a succesful query...

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > Using a mySQL result


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT