情况是这样,现在table1 中name字段,存有以各种字母开头的字符串,
我想检索以字母或数字开头的数据
table1:
name
123

三三
abc
ABK要检索
name
123
abc
ABK
怎么写?
我新手不太会,高手给写下。。谢谢

解决方案 »

  1.   

    如果只有字母,数字,汉字开头的话
    select * from table1 where lengthb(substr(name,1,1)) <2;
    这样写就可以了.
      

  2.   

    多谢79bo(山芋) 兄弟启发,
    不过你写得不对
    应该是
    select * from table1 where lengthb(to_char(substr(name,1,1)))=1
      

  3.   

    我的死9I,难道和你10G不一样?
    SQL> create table table1(name varchar2(10));表已创建。SQL> insert into table1 values('name');已创建 1 行。SQL> insert into table1 values('123');已创建 1 行。SQL> insert into table1 values('阿');已创建 1 行。SQL> insert into table1 values('三三');已创建 1 行。SQL> insert into table1 values('abc');已创建 1 行。SQL> insert into table1 values('ABK');已创建 1 行。SQL> commit;提交完成。SQL> select * from table1;NAME
    ----------
    name
    123

    三三
    abc
    ABK已选择6行。SQL> select * from table1 where lengthb(substr(name,1,1)) <2;NAME
    ----------
    name
    123
    abc
    ABK