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
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!
> ellisjb_at_my-deja.com wrote:
>
> > A simplified example: my table has two columns, data (varchar) and
> > Contents (varchar). I want to store a list of integers in Contents,
> > e.g. '1,2,3,4,5', and do a query like
> >
> > select data from mytable where 2 in contents;
> >
> > But this setup doesn't give the desired results; apparently, a
> > comma-delimited list in a column can't be used in a "where ... in"
> > query this way.
> >
> > Is there a simple way to accomplish this? Or do I need to have
> > to re-organize my tables?
Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Wed Jan 19 2000 - 09:39:41 CST
![]() |
![]() |