Re: Who helps me solve an SQL problem?

From: Will Pedersen <will_at_netgate.net>
Date: 1996/06/16
Message-ID: <31C4824D.3FE7_at_netgate.net>#1/1


Ben Van Hool wrote:
>
> Who can help me solve this SQL problem?
>
> Suppose I have more than one strings str1, str2, str3,... strn and I
> want to check whether they all appear in a particular field.
>
> To check just one I can use:
>
> select * from mytable where instr(myfield,str1)>0
>
> (although I don't know if this is the best)
>
> But what if there are more str and the number varies?
>
> I solved it using PLSQL but it looks so complicated that I think there
> must be a real easy way. What's more: my solution is very slow.
>
> TIA, Ben.

This should be easy enough to do using an "and" construct:

 select * from mytable

	where instr(myfield,str1)>0
		and instr(myfield,str2)>0
		and instr(myfield,str3)>0
	....
Received on Sun Jun 16 1996 - 00:00:00 CEST

Original text of this message