当前位置:首页
开发技术指南» 文章正文
    引言:

    摘要: #include<iostream.h> #include<cstdlib> //using namespace std; struct student { int id; //学号 float gpa; //平均分 }; template <class t> class store { public: store(void); t getite......
    摘要: 调用模板deque中的erase函数删除元素,是否自动调用了该元素的析构函数? ......


求一Sql语句

表结构   ID     UserIds  
  记录         1         2,3,4,  
                  2           5,  
                  3           2,  
   
  求一sql语句   找出userids字段含有2的记录   谢谢

NO.1   作者: xiaonvjing

这样最好啦,  
   
   
  select   *   from   table1   where   charindex   (2,userids   )!=0

NO.2   作者: filebat

to     huohw:  
  ID     UserIds  
  1         2,3,4,  
  2           5,1  
  3           2,  
  4           1,   2,  
  5           1,   12,  
  找出userids字段含有2的记录,我想结果应该是:  
  1           2,3,4,  
  3           2,  
  4           1,   2,  
 

NO.3   作者: zlp321002

--测试环境  
  declare   @t   table(ID   int   identity(1,1),UserIds   varchar(20))  
  insert   into   @t   select   2,3,4  
  union   all   select   5,1  
  union   all   select   2,  
  union   all   select   1,2,  
  union   all   select   1,   12,  
   
  --执行查询  
  select   *   from   @t   where   charindex(,2,,,+UserIds+,)>0  
   
  --结果  
   
  ID                     UserIds                              
  -----------   --------------------    
  1                       2,3,4  
  3                       2,  
  4                       1,2,  
   
   
 

NO.4   作者: MorningTea

select   *   from   ta   where   userids   like   %,2,%   or   userids   like   2,%

NO.5   作者: qxq321

如此:  
  select   *   from   table1   where   userids   like   %,2,%   or   userids   like   2,%   or   userids   like   %,2  
 


    摘要: 如题 ,现在在任务管理器都用不起来了,重分酬谢!!!! ......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE