我现在有两个字段   ClassId  ClassList  我现在ClassId是知道的,怎样写SQL  条件就是ClassId在ClassList中

解决方案 »

  1.   

    select * from tb a,tb b where a.ClassId=b.ClassList
      

  2.   

    select * from tb t where exists(select 1 from tb where ClassId=a.ClassList)
      

  3.   


    select * from tb where ClassId in (select ClassList from tb)
      

  4.   

    select * from tb where ClassId in (select ClassList from tb)select m.* from tb m where exists(select 1 from tb n where n.ClassList = m.ClassId)
      

  5.   

    如果classidlist 中的classid 是用 逗号 分隔的话:
    where charindex(','+classid+',',','+classidlist+',')>0
      

  6.   

    我的ClassList是数据库中的,而ClassId不是数据库中的
      

  7.   

    用一些实例告诉我们,你的 classid 和 classidlist 分别长什么样儿.
      

  8.   

    ClassId :201112021228458593
    ClassList:201112021228458593,201112021229246875,