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 database

MySQL database

Scheduled Pinned Locked Moved Database
databasemysqlhelptutorialquestion
5 Posts 3 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.
  • A Offline
    A Offline
    Alboyz
    wrote on last edited by
    #1

    how to make number 56,500,51 in MySQL I tried to make a function in MySQL like this

    CREATE FUNCTION `fTITIK`(number double(8,2)) RETURNS VARCHAR(255) CHARSET latin1
    DETERMINISTIC
    BEGIN DECLARE hasil VARCHAR(255);
    SET hasil = REPLACE(REPLACE(REPLACE(FORMAT(number, 2), '.', '|'), ',', '.'), '|', ','); RETURN (hasil);
    END

    hen when it starts it only appears 56,500 while the numbers that are behind the comma do not work any suggestion? what should I fix?

    R M 2 Replies Last reply
    0
    • A Alboyz

      how to make number 56,500,51 in MySQL I tried to make a function in MySQL like this

      CREATE FUNCTION `fTITIK`(number double(8,2)) RETURNS VARCHAR(255) CHARSET latin1
      DETERMINISTIC
      BEGIN DECLARE hasil VARCHAR(255);
      SET hasil = REPLACE(REPLACE(REPLACE(FORMAT(number, 2), '.', '|'), ',', '.'), '|', ','); RETURN (hasil);
      END

      hen when it starts it only appears 56,500 while the numbers that are behind the comma do not work any suggestion? what should I fix?

      R Offline
      R Offline
      realJSOP
      wrote on last edited by
      #2

      It looks like the value represents a floating point number (or currency. If that's the case, don't store it as a string. The app that uses the data is responsible for correctly formatting the value for display purposes.

      ".45 ACP - because shooting twice is just silly" - JSOP, 2010
      -----
      You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
      -----
      When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

      A 1 Reply Last reply
      0
      • A Alboyz

        how to make number 56,500,51 in MySQL I tried to make a function in MySQL like this

        CREATE FUNCTION `fTITIK`(number double(8,2)) RETURNS VARCHAR(255) CHARSET latin1
        DETERMINISTIC
        BEGIN DECLARE hasil VARCHAR(255);
        SET hasil = REPLACE(REPLACE(REPLACE(FORMAT(number, 2), '.', '|'), ',', '.'), '|', ','); RETURN (hasil);
        END

        hen when it starts it only appears 56,500 while the numbers that are behind the comma do not work any suggestion? what should I fix?

        M Offline
        M Offline
        Mycroft Holmes
        wrote on last edited by
        #3

        Do your data formatting in the user interface (that includes reports). NEVER do it in the database and as John said never store your numbers as strings ALWAYS use the correct data format. This also applies to dates, store them as DATE or DATETIME, never as strings.

        Never underestimate the power of human stupidity - RAH I'm old. I know stuff - JSOP

        A 1 Reply Last reply
        0
        • R realJSOP

          It looks like the value represents a floating point number (or currency. If that's the case, don't store it as a string. The app that uses the data is responsible for correctly formatting the value for display purposes.

          ".45 ACP - because shooting twice is just silly" - JSOP, 2010
          -----
          You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
          -----
          When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

          A Offline
          A Offline
          Alboyz
          wrote on last edited by
          #4

          Thank you for the advice

          1 Reply Last reply
          0
          • M Mycroft Holmes

            Do your data formatting in the user interface (that includes reports). NEVER do it in the database and as John said never store your numbers as strings ALWAYS use the correct data format. This also applies to dates, store them as DATE or DATETIME, never as strings.

            Never underestimate the power of human stupidity - RAH I'm old. I know stuff - JSOP

            A Offline
            A Offline
            Alboyz
            wrote on last edited by
            #5

            Thank you for the advice

            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