mysql 求一语句。mytable中 有一字段:upRange  属性为varchar(6)  值都是些:+0.56 +7.89 +3.33 -5.45 -3.00 -0.02 及一些空值用 --表示。
怎样select 其中字段值 >= +7.00 or <= -7.00 的记录呢 ??
不知道这么说 大家明白不??

解决方案 »

  1.   

    自己回答吧 :select * from mytable where upRange>=+7.00 
                select * from mytable where upRange<=-7.00
      

  2.   

    SELECT * 
    FROM mytable
    WHERE upRange IS NOT NULL
        AND (CAST(upRange AS SIGNED) >= 7 
           OR CAST(upRange AS SIGNED) <= -7);
      

  3.   

    select * from mytable where upRange>=+7.00 
                select * from mytable where upRange <=-7.00
    这样也行啊 
      

  4.   

    MySQL会对数据进行隐式的转换。比如 
    mysql> select 1+'1','1'+'1',2>'1';
    +-------+---------+-------+
    | 1+'1' | '1'+'1' | 2>'1' |
    +-------+---------+-------+
    |     2 |       2 |     1 |
    +-------+---------+-------+
    1 row in set (0.16 sec)mysql>
    若要在数值语境中将一个字符串派给一个数值, 通常情况下,除了将字符串值作为数字使用外,你不需要做任何事:mysql> SELECT 1+'1';       -> 2若要在一个字符串语境中使用一个数字,该数字会被自动转化为一个BINARY 字符串。mysql> SELECT CONCAT('hello you ',2);        -> 'hello you 2'
      

  5.   

    中文版的手册少了很多内容。参见下面英文中的解释得比较详细。http://dev.mysql.com/doc/refman/5.1/en/type-conversion.html
    11.2.2. Type Conversion in Expression Evaluation
      

  6.   

    1、自己解决更好;
    2、MYSQL进行了转换;
    3、
    select * from mytable where upRange>=+7.00 
                select * from mytable where upRange <=-7.00ORselect * from mytable where 0+upRange>=+7.00 
                select * from mytable where 0-upRange <=-7.00
      

  7.   

    在MYSQL HELP中有说明,MYSQL自己进行了转换
    select * from mytable where 0+upRange>=+7.00
    select * from mytable where 0-upRange <=-7.00When an operator is used with operands of different types, type conversion occurs to make the operands compatible. Some conversions occur implicitly. For example, MySQL automatically converts numbers to strings as necessary, and vice versa. mysql> SELECT 1+'1';
            -> 2
    mysql> SELECT CONCAT(2,' test');
            -> '2 test'
      

  8.   

    wwwwa 和 wwwwb  是同一个人吗??