Announcement

Collapse
No announcement yet.

Calculated field using an int and a varchar

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Calculated field using an int and a varchar

    I want to create a calculated field using an int and a varchar. the end result will be: 100 lbs of Junk, where 100 is from an int field, lbs is a string, and "of Junk" is in a varchar

    My calculated field expression is the following, but it errors out:

    Concat( cast(lots.LbsJunk char(25)), " lbs: ", lots.JunkComment)

    lots.LbsJunk = 100
    lots.JunkComment = "of Junk"

    What am I doing wrong?

  • #2
    Hi Ikaatz

    Please provide the error message and your server version.

    Comment


    • #3
      Invalid SQL statement.
      1064 - you have an error in your sql syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'char(25)), "lbs: ", lots.JunkComment) AS Concat_cast_lots_LbsJunk FROM `lots`' at line 50

      Concat( cast(lots.LbsJunk char(25)), " lbs: ", lots.JunkComment)

      version: 5.6.16

      Comment


      • #4
        The CAST function syntax is CAST(expr AS type)

        For more information, please refer to - https://dev.mysql.com/doc/refman/5.7...#function_cast

        Comment

        Working...
        X