SitePoint Sponsor

User Tag List

Results 1 to 9 of 9

Thread: sum one row

  1. #1
    SitePoint Addict
    Join Date
    Mar 2005
    Posts
    319
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    sum one row

    PHP Code:
    $to mysql_fetch_object(mysql_query("SELECT SUM(*) as total FROM $forumzDB.unz_browser WHERE brid = '1'")) or die(mysql_error()); 
    I get a mysql error at *)

  2. #2
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    because * is not a vaild parameter for sum(). what are you trying to do?

  3. #3
    SitePoint Addict
    Join Date
    Mar 2005
    Posts
    319
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    brid | brow | brow1 | brow2 | brow3
    1 ------2-------55-------2--------77

    I want to sum the brid 1 row!

  4. #4
    SitePoint Wizard guelphdad's Avatar
    Join Date
    Oct 2003
    Location
    St. Catharines, ON Canada
    Posts
    1,708
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    select (brow+brow1+brow2+brow3) from yourtable whrere brid=1

  5. #5
    SitePoint Addict
    Join Date
    Mar 2005
    Posts
    319
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Gah, no easier way? Theres 13 of them

  6. #6
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,341
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by azz0r_wugg
    Gah, no easier way? Theres 13 of them
    why are there 13 of them? what happens when a new "brow" is required?

    sounds like they should be rows, not columns
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  7. #7
    SitePoint Addict
    Join Date
    Mar 2005
    Posts
    319
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Indeed, I recoded my graph and redid the table

    browser no desc
    MAXTHON 0 Maxthon
    OPERA 0 Opera
    MSIE 2 Internet Explorer
    NETSCAPE 2 Netscape
    FIREFOX 0 Firefox
    SAFARI 0 Safari
    KONQUEROR 0 Konqueror
    MOZILLA 0 Mozilla
    OTHER 3 Unknown

  8. #8
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,341
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    so now you can use SUM() comfortabley, yes?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  9. #9
    SitePoint Addict
    Join Date
    Mar 2005
    Posts
    319
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Indeed, thanks!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •