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%'没有执行
可能我说得不清楚,我把代码贴出来: 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: 无效的过程调用
你用的是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#把+都换成&
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
给你个思路,你自己试个看能不能达到你的目的: 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%' )
本身就是错误的
这样应该也行
select * from A1 where B1 like '%n%' and B1 like '%o%' and B1 like '%m%'
也不行啊,
只执行了B1 in (select B1 from A1 where B1 like '%m%'),
而 B1 like '%n%' and B1 like '%o%'没有执行
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: 无效的过程调用
dim tSQL as string = "select * from ziyuan where " 这句是vb.net的
而tsql=tsql+" guige in(select guige from ziyuan where guige like '%*%*%') "里面的+又表明是c#把+都换成&
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
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%' )
我用了个笨办法,如果为负值就用个OR 来个无厘头得条件,结果发现通过测试了
谢谢各位啦