从一个表中读取一个字段,这个字段是varchar(200)类型的,现在需要从读取结果中过滤出全部为数字的结果,用sql语句怎么实现?select column from tablename where column ......后面该怎么写?(字段里面的数据长度不是固定的)

解决方案 »

  1.   

    select column from tablename where rtrim(column,'0123456789') is null
    说明全部为数字
      

  2.   

    如果column两边有空格可以rtrim(trim(column),'0123456789') is null
      

  3.   

    不对啊,rtrim是去空格的,不是过滤的啊
      

  4.   

    try:select * from tablename WHERE trim(translate(column,' 1234567890',' ')) IS NULL
      

  5.   

    ltrim(str,chr)和rtrim(str,chr)也可以的,不加第2个参数默认是去掉空格,加了参数后就可以过滤掉参数里的字符,注意是过滤掉字符集合里的元素,不是过滤整个字符串
    这种写法也是正确的:where ltrim(column,' 0123456789')
      

  6.   

    大概是我表达的不清楚,我的意思是读取表中数据全部是数字的结果,不是要改变结果
    这个过滤用的不准确sorryselect column from table where ......使select的查询结果是column字段中全部是数字的数据
      

  7.   

    SQL> create table A
      2  (
      3  A1 VARCHAR2(10)
      4  )
      5  /Table createdSQL> 
    SQL> insert into a values('qqqqqq');1 row insertedSQL> insert into a values('1234767');1 row insertedSQL> insert into a values('123wwww');1 row insertedSQL> insert into a values('123');1 row insertedSQL> insert into a values('eeeee123');1 row insertedSQL> insert into a values('33ee13');1 row insertedSQL> insert into a values('ee33ee13');1 row insertedSQL> select a1 from a where rtrim(a1,'0123456789') is null;A1
    ----------
    1234767
    123你不是要类似这样的需求吗?应该没有理解错吧?