某表  字段value 是 integer
value-------time
80-----------1
90-----------2
我查2的90-1的80 结果是10如果value值对调
value-------time
90-----------1
80-----------22的80-1的90mysql tool里 结果是不知道多少为的数字在EMS里 结果是0我只是对我出现的问题做一个概述,不知道你们会是怎样一个情况。后来把value换成double型   就能得出负10了  为什么?

解决方案 »

  1.   

    你是怎样定义VALUE字段的
    INT[(M)] [UNSIGNED] [ZEROFILL] A normal-size integer. The signed range is -2147483648 to 2147483647. The unsigned range is 0 to 4294967295. 
      

  2.   

    select a.value-b.valefrom 表where a.time=2 and a.time=1-----------------------------
    select value-(select a.value from 表 a where a.time=1)from 表where time=2
    SQL 用的就是这2种数值范围不清楚 就是通过工具建表 选个int型 其他因该都是默认的我实际情况就是用上面的SQL 1W7多 - 1W8多  在MYSQL tool里结果是上亿
    [UNSIGNED] [ZEROFILL] 这2个属性都是打勾的
      

  3.   

    show create table 表;
     看一下,应该不会有你说的这种问题。
      

  4.   

    恩.........改回int型  把有符号的勾去掉  运算结果正常了  打上钩又不对了
      

  5.   

    [UNSIGNED] [ZEROFILL] 这2个属性都是打勾的The unsigned range is 0 to 4294967295.如果有负数,取勾
      

  6.   

    mysql> create table t_Lie_li(value int UNSIGNED ZEROFILL ,time int);
    Query OK, 0 rows affected (0.08 sec)mysql> insert into t_Lie_li values
        -> (80,1),
        -> (90,2);
    Query OK, 2 rows affected (0.05 sec)
    Records: 2  Duplicates: 0  Warnings: 0mysql>
    mysql> select * from t_Lie_li;
    +------------+------+
    | value      | time |
    +------------+------+
    | 0000000080 |    1 |
    | 0000000090 |    2 |
    +------------+------+
    2 rows in set (0.00 sec)mysql> select a.value-b.vale
        -> from t_Lie_li a,t_Lie_li b
        -> where a.time=2 and a.time=1;
    ERROR 1054 (42S22): Unknown column 'b.vale' in 'field list'
    mysql> select a.value-b.value
        -> from t_Lie_li a,t_Lie_li b
        -> where a.time=2 and a.time=1;
    Empty set (0.00 sec)mysql> select a.value-b.value
        -> from t_Lie_li a,t_Lie_li b
        -> where a.time=2 and b.time=1;
    +-----------------+
    | a.value-b.value |
    +-----------------+
    |              10 |
    +-----------------+
    1 row in set (0.00 sec)mysql> select value-(select a.value from t_Lie_li a where a.time=1)
        -> from t_Lie_li
        -> where time=2;
    +-------------------------------------------------------+
    | value-(select a.value from t_Lie_li a where a.time=1) |
    +-------------------------------------------------------+
    |                                                    10 |
    +-------------------------------------------------------+
    1 row in set (0.00 sec)mysql>
      

  7.   


    sorry,没用过图形界面
    只知道你设置为"signed"类型就可以了。
      

  8.   

    int 的符号问题signed和unsigned