Professional Web Applications Themes

cast function problems - MySQL

Hi, In one of my tables, one of the columns (Salary) is of type varchar(255). I want to conver it into int(11). When I do a test to see if get the result, I have the following problems. select cast(Salary as unsigned int) from mydb; Truncated incorrect INTEGER value: '150000.00' ie, if the Salary has a decimal point, it gives me an error. Any suggestions? Thanks....

  1. #1

    Default cast function problems

    Hi,
    In one of my tables, one of the columns (Salary) is of type
    varchar(255). I want to conver it into int(11). When I do a test to
    see if get the result, I have the following problems.

    select cast(Salary as unsigned int) from mydb;

    Truncated incorrect INTEGER value: '150000.00'


    ie, if the Salary has a decimal point, it gives me an error. Any
    suggestions?

    Thanks.

    PGPS Guest

  2. #2

    Default Re: cast function problems

    Actually, I am trying to insert this salary value ( from varchar(255))
    into a table which has a type int(11). Thats when I get this trouble.
    insert into mydb2 (select cast(Salary as unsigned int) from mydb)

    Truncated incorrect INTEGER value: '150000.00'

    mydb2 has Salary int(11);

    Thanks.

    On Apr 17, 5:39 pm, PGPS <com> wrote: 


    PGPS Guest

  3. #3

    Default Re: cast function problems

    Found the solution myself, the problem was solved if I convert the
    varchar to decimal and then to integer

    cast(cast(SalaryMin as decimal(8,0)) as unsigned integer


    PGPS Guest

Similar Threads

  1. using the cast function
    By don in forum MySQL
    Replies: 3
    Last Post: June 29th, 06:47 PM
  2. External Cast Problems...still
    By Lutris Man in forum Macromedia Director Basics
    Replies: 0
    Last Post: May 4th, 02:58 AM
  3. Problems with external cast
    By Firefigther in forum Macromedia Director Lingo
    Replies: 2
    Last Post: February 22nd, 05:22 PM
  4. Problems importing GIFS into Cast.
    By Harpoonface webforumsuser@macromedia.com in forum Macromedia Director Basics
    Replies: 1
    Last Post: January 29th, 06:21 PM
  5. Cast Problems
    By Bodhisattvan webforumsuser@macromedia.com in forum Macromedia Director Basics
    Replies: 3
    Last Post: January 19th, 06:04 AM

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139