Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Trying to use "where in" to select from a list
On Wed, 19 Jan 2000 15:39:41 GMT, ellisjb_at_my-deja.com wrote:
>In article <388586D4.9F704E2B_at_gaul-edin.freeserve.co.uk>,
> "Ken Gaul (06)" <ken_at_gaul-edin.freeserve.co.uk> wrote:
>> If I understand correctly what you want is
>>
>> select data from mytable where instr(contents,'2')>0
>
>Yes, that's right! Except this also returns rows where contents
>contained '20'. But this will work if I do instr(contents, '2,') > 0
>and just make sure that my list ends on a comma. I think that's
>what I'll do... Thanks!
'2,' is not selective enough either - you'll get a match on 12 as well
:-(. So you have to look for ',2,' . And to make allowance for the
first and last items in the contents, make it like this:
where instr(','+contents+',', ',2,') >0
also, instead of instr() you can use LIKE:
where ','+contents+',' LIKE '%,2,%' Received on Wed Jan 19 2000 - 12:06:55 CST