有N张表的结构如下:x1 x2 y1 y2 single类型。area double类型。
id x1 x2 y1 y2 area
1  10 15 11 13 200
2  11 13 13 14 200
3  13 14 14 16 200
4  14 16 10 15 200
5  13 14 12 14 200
6  12 14 10 15 200
要求查询x在x1和x2之间,y在y1和y2之间之间的所有结果?
("select * from 表 where '" + x + "' between x1 and x2 and '" + y + "' between y1 and y2 and area is not null");
请问哪里有错?怎么修改?谢谢。。

解决方案 »

  1.   

    select * from 表 where ('" + x + "' between x1 and x2) and ('" + y + "' between y1 and y2) and area is not null
      

  2.   

    --x,y不是字串,因此不要加单引号("select * from 表 where " + x + " between x1 and x2 and " + y + " between y1 and y2 and area is not null");
      

  3.   

    x,y是作为参数传进来的,虽然说是double,但是字串呀
      

  4.   

    参数传过来是字串,那么要转换一下:
    ("select * from 表 where to_number(" + x + ") between x1 and x2 and to_number(" + y + ") between y1 and y2 and area is not null");或者:
    ("select * from 表 where " + x + "+0 between x1 and x2 and " + y + "+0 between y1 and y2 and area is not null");