数据库字段 
RegionCode [varchar(12)]
450904001000
450904002000
450904003000
450904004000
...
450904999000现在我想查询 第6为到第9为之间   大于100  小于<300 的代码怎么写?小弟分少 请原谅!!

解决方案 »

  1.   

    select * from table where convert(int,substring(RegionCode,6,3))>100 and convert(int,substring(RegionCode,6,3))<300
      

  2.   

    select * from [tableName] where substring(RegionCode,6,9) between 100 and 300
      

  3.   

    不好意思,错了。
    是:select * from [tableName] where substring(RegionCode,6,3) between 100 and 300
      

  4.   

    select * from [tableName] where Cast(substring(RegionCode,6,3),int) between 100 and 300
      

  5.   

    HQL  是 HQL !!!兄弟们 如果是SQL 就不用求你们了!