给你个思路,你自己试个看能不能达到你的目的:
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%' )
你用的是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+""
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%'没有执行