SELECT * FROM table WHERE id LIKE '01%';

解决方案 »

  1.   

    SELECT * FROM table WHERE id LIKE  '01% ';  这样不可以,因为我还有些数据是 01  02   03 两位的;
    substring(id,0,2)这样也是错误的,我也试过。
    继续求助
      

  2.   

    可是使用LIKE的话那么像0201,0301等不是也取出来了吗?
    期待解答
      

  3.   

    select   id,name   from   news   where   substring(id,1,2)=01 
    (不要 as id )我测试拉在 postgressql中通过,不知道楼主是什么DB.
      

  4.   

    select       id,name       from       news       where       substring(id,1,2)=01   
    或者
    select       id,name       from       news       where       id like '01%'
      

  5.   

    select   id,   substring(id,0,2)   as   sid   ,name   from   news   where  substring(id,0,2) = '01%'  
    这样是应该是的。
      

  6.   

    select
    *
    from
    tmp
    where
    substring(id,1,2)=01 or substring(id,1,2)=02 or substring(id,1,2)=03