Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. MYSQL SUM SEVERAL COLUMN VALUES

MYSQL SUM SEVERAL COLUMN VALUES

Scheduled Pinned Locked Moved Database
csharpmysqljson
7 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    KipkoechE
    wrote on last edited by
    #1

    I have mysql table which stores students marks. The first column represent the unique Regno For each student, the second reprsents TotalScore and the rest of the rows represent units name. Note...The columns representing different can be increased if a new unit is added. Therefore i wish to know how i can loop through the records of each student ,add them and insert into TotalScore column...am still new to vb.net. Kindly assist the table is as follows: REGNO TOTALSCORE UNIT1,unit2,unit3,unit4,...UNITn 1 2 3 . . n

    Richard Andrew x64R 1 Reply Last reply
    0
    • K KipkoechE

      I have mysql table which stores students marks. The first column represent the unique Regno For each student, the second reprsents TotalScore and the rest of the rows represent units name. Note...The columns representing different can be increased if a new unit is added. Therefore i wish to know how i can loop through the records of each student ,add them and insert into TotalScore column...am still new to vb.net. Kindly assist the table is as follows: REGNO TOTALSCORE UNIT1,unit2,unit3,unit4,...UNITn 1 2 3 . . n

      Richard Andrew x64R Offline
      Richard Andrew x64R Offline
      Richard Andrew x64
      wrote on last edited by
      #2

      KipkoechE wrote:

      i wish to know how i can loop through the records of each student and insert into TotalScore column

      What do you want to insert into the TotalScore column?

      The difficult we do right away... ...the impossible takes slightly longer.

      K 1 Reply Last reply
      0
      • Richard Andrew x64R Richard Andrew x64

        KipkoechE wrote:

        i wish to know how i can loop through the records of each student and insert into TotalScore column

        What do you want to insert into the TotalScore column?

        The difficult we do right away... ...the impossible takes slightly longer.

        K Offline
        K Offline
        KipkoechE
        wrote on last edited by
        #3

        The sum of each row as identified by the regno

        Richard Andrew x64R 1 Reply Last reply
        0
        • K KipkoechE

          The sum of each row as identified by the regno

          Richard Andrew x64R Offline
          Richard Andrew x64R Offline
          Richard Andrew x64
          wrote on last edited by
          #4

          How about executing the query:

          UPDATE tablename SET TotalScore = (unit1 + unit2 + unit3 + unit4) // and so on?

          The difficult we do right away... ...the impossible takes slightly longer.

          K 1 Reply Last reply
          0
          • Richard Andrew x64R Richard Andrew x64

            How about executing the query:

            UPDATE tablename SET TotalScore = (unit1 + unit2 + unit3 + unit4) // and so on?

            The difficult we do right away... ...the impossible takes slightly longer.

            K Offline
            K Offline
            KipkoechE
            wrote on last edited by
            #5

            AM trying to avoid that method because the number of columns can be changed at runtime

            Richard Andrew x64R 1 Reply Last reply
            0
            • K KipkoechE

              AM trying to avoid that method because the number of columns can be changed at runtime

              Richard Andrew x64R Offline
              Richard Andrew x64R Offline
              Richard Andrew x64
              wrote on last edited by
              #6

              KipkoechE wrote:

              the number of columns can be changed at runtime

              How is that possible? Are you creating a new table with a different number of columns and then deleting the first table?

              The difficult we do right away... ...the impossible takes slightly longer.

              K 1 Reply Last reply
              0
              • Richard Andrew x64R Richard Andrew x64

                KipkoechE wrote:

                the number of columns can be changed at runtime

                How is that possible? Are you creating a new table with a different number of columns and then deleting the first table?

                The difficult we do right away... ...the impossible takes slightly longer.

                K Offline
                K Offline
                KipkoechE
                wrote on last edited by
                #7

                By altering the table when a new unit is added

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups