1  select * from A1 where B1 like 'm'2  select * from A1 where B1 like 'n' and 'o'前提是必须先根据1筛选,再从1筛选得结果里进行2筛选,否则就会出错,请问应该怎麽写?

解决方案 »

  1.   

    select * from A1 where B1 like 'n' and 'o'
    本身就是错误的
      

  2.   

    select * from A1 where B1 like '%n%' and B1 like '%o%' and B1 in (select B1 from A1 where B1 like '%m%')
      

  3.   

    楼上正解,
    这样应该也行
    select * from A1 where B1 like '%n%' and B1 like '%o%' and B1 like '%m%'
      

  4.   

    skyfarwolf(Computer) 得方法我试过得,绝对不行.我来试试 singlepine(小山) 得方法
      

  5.   

    select * from A1 where B1 like '%n%' and B1 like '%o%' and B1 in (select B1 from A1 where B1 like '%m%')
    也不行啊,
    只执行了B1 in (select B1 from A1 where B1 like '%m%'),
    而 B1 like '%n%' and B1 like '%o%'没有执行
      

  6.   

    可能我说得不清楚,我把代码贴出来: dim tSQL as string = "select * from ziyuan where "
     tsql=tsql+" guige in(select guige from ziyuan where  guige like '%*%*%')  "
       tsql=tsql+" and left(guige,instr(guige,'*')-1) between  "+strzyggh1+"  and  "+strzyggh2+""
       tsql=tsql+" and  Mid(guige,InStr(guige,'*')+1 ,InStr(InStr(guige,'*')+1,guige,'*')-InStr(guige,'*')-1) "
       tsql=tsql+" between "+strzyggk1+" and "+strzyggk2+""    tsql=tsql+" order by shijian DESC"测试后提示:System.Data.OleDb.OleDbException: 无效的过程调用
      

  7.   

    你用的是vb.net,还是c#
    dim tSQL as string = "select * from ziyuan where " 这句是vb.net的
    而tsql=tsql+" guige in(select guige from ziyuan where  guige like '%*%*%')  "里面的+又表明是c#把+都换成&
      

  8.   

    dim tSQL as string = "select * from ziyuan where "
     tsql=tsql & " guige in(select guige from ziyuan where  guige like '%*%*%') "   tsql=tsql & " and left(guige,instr(guige,'*')-1) between  "& strzyggh1 & " and  " & strzyggh2 & ""
       tsql=tsql &" and  Mid(guige,InStr(guige,'*')+1 ,InStr(InStr(guige,'*')+1,guige,'*')-InStr(guige,'*')-1) "
       tsql=tsql & " between " & strzyggk1 &" and " & strzyggk2 &""    tsql=tsql & " order by shijian DESC"
    test
      

  9.   

    给你个思路,你自己试个看能不能达到你的目的:
    select mytable.A 
    from mytable,mytable as T1,mytable as T2,mytable as T3
    where 
    mytable.ID=T1.ID and T1.ID=T2.ID and T2.ID=T3.ID and
    mytable.B in (select B from T1 where B like '%m%' ) and
    mytable.B in (select B from T2 where B like '%n%' ) and
    mytable.B in (select B from T3 where B like '%o%' )
      

  10.   

    提示 : +或者&其实都可以得
    我用了个笨办法,如果为负值就用个OR 来个无厘头得条件,结果发现通过测试了
    谢谢各位啦