Thanks for the help.  As often happens in these situations, a little
searching and experimentation got me a workable answer before any replies
arrived.

In my case, I was able to use the LOCATE operator, i.e.

select idx, lname,schedalonerscs from usrs where LOCATE(",7,",
schedalonerscs) != 0;

I'm very sensitive to the observations of Peter Bradley.  This is the first
thing I've done with MySQL, and I didn't know in advance how fast it was or
was not.  On the page:

http://fboprimedevel.e3ft.com

the "day view scheduler page" has to load rather quickly.  I was rather
cautious to have a simple design for the database.  Now that I understand it
all a bit better, my next project might use MySQL the "right" way.

Thanks, Dave.


On 11/4/06, Dan Buettner <[EMAIL PROTECTED]> wrote:

Dave, you could just use a LIKE statement

SELECT *
FROM table
WHERE mystring LIKE "%,2,%"

Of course if it is at the beginning or end, or the only item, it may
look like '2' '2,' or ',2' and not ',2,' so this would work in all
cases I think:

WHERE (mystring LIKE "%,2,%" OR mystring LIKE "2,%" OR mystring LIKE
"%,2" OR mystring = "2")

Performance will be terrible if this grows much but for a trivial
implementation it should work.

Dan



On 11/4/06, David T. Ashley <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm a little bit lost on MySQL statements.
>
> I am implementing a many:many relationship using a string (wrong way, I
> know, but I'm trying to keep the design simple and this is a trivial
> application).
>
> In a VARCHAR field, I will store a comma-delimited set of integers
> corresponding to the indices in another table.  It might look like:
>
> ,1,2,9,
>
> to specify a link to records 1, 2, and 9.
>
> I'm not sure how to find, for example, all records where the text of a
given
> field contains ",2,".
>
> I'm not interested in an efficient search, just a search.  I know it
will be
> O(N) unless indexing of some kind is used.
>
> My explanation above might be confusing, so let me give an example that
will
> give the same answer ...
>
> Suppose I'm interested in searching a table for all records with last
names
> that contain "sh".  How would I do that?
>
> (Different problem, same answer.)
>
> Thanks, Dave.
>
>

Reply via email to