本帖最后由 ww2128228 于 2011-07-24 10:27:31 编辑

解决方案 »

  1.   

    SELECT * FROM t2 order by abs(value-字段A) 
      

  2.   

    select * from 一张表 where 给定一个值 between 最小值 and 最大值
      

  3.   

    这里的常量8是你传入的参数值:
    mysql> use test;
    Database changed
    mysql> create table tb_test(maxValue int,minValue int,otherCol varchar(10));
    Query OK, 0 rows affected (0.04 sec)mysql> insert into tb_test
        -> select 5,2,'A'
        -> union all
        -> select 10,7,'B';
    Query OK, 2 rows affected (0.00 sec)
    Records: 2  Duplicates: 0  Warnings: 0mysql> select * from tb_test where minValue<=8 and maxValue>=8;
    +----------+----------+----------+
    | maxValue | minValue | otherCol |
    +----------+----------+----------+
    |       10 |        7 | B        |
    +----------+----------+----------+
    1 row in set (0.00 sec)