Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2003

    Unanswered: str() function equivalent for mysql?

    In sql server the str() function converts numeric data into character data. Is there any such function in mysql?



  2. #2
    Join Date
    Nov 2003
    The closest thing to STR() that MySQL has is FORMAT().

    Formats the number X to a format like '#,###,###.##', rounded to D decimals, and returns the result as a string. If D is 0, the result will have no decimal point or fractional part:
    mysql> SELECT FORMAT(12332.123456, 4);
    -> '12,332.1235'
    mysql> SELECT FORMAT(12332.1,4);
    -> '12,332.1000'
    mysql> SELECT FORMAT(12332.2,0);
    -> '12,332'

    You may also want to look into CAST or CONVERT.
    CAST() and CONVERT() are available as of MySQL 4.0.2.

Posting Permissions

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