> -----Original Message-----
> From: Jon Shoberg [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, January 13, 2002 4:47 PM
> To: Beginners (E-mail)
> Cc: *MySQL mail list; Jon Shoberg
> Subject: Regexp Help !!!
>
>
> Ok,
>
>       I have a list/database of words that follows as ...
>
> Top
> ...
> Top/Arts/Food
> Top/Arts/Food/Country
> ...
> Top/World/America
> Top/World/Japan
> Top/World/Japan/Economy
> Top/World/Japan/Food
> Top/World/Japan/Food/Country
> Top/World/Japan/Food/Country/By_Chef
>
> ...
>
> How can I setup a regexp query/filter such that I can choose the
> prefix and
> the number of "/" in the results?
>
> Example: How can I query/filter the list such that I am looking for all
> "Top/World/" matches that have only one more word after them.  So my only
> results from the example about would be "Top/World/America" and
> "Top/World/Japan".  Then I would do the same for "Top/World/Japan" and get
> "Top/World/Japan/Economy" and then "Top/World/Japan/Food".  This
> is part of
> the program so I can count the number of "/" in the query/filter
> string.  I
> jsut want to exclude the extra matches.
>
> Any thoughts?
>
> Thanks
> Jon

Not sure I would do it using regexps. Unless I misunderstand what
you're trying to do, I would consider using LIKE as this will often
be much faster:

SELECT ...
WHERE data LIKE "TOP/World/Japan/%"
  AND data NOT LIKE "TOP/World/Japan/%/%"

- in essence: select all those records which start with
"TOP/World/Japan/", then subtract those which contain
any further "/".

/ Carsten
--
Carsten H. Pedersen
keeper and maintainer of the bitbybit.dk MySQL FAQ
http://www.bitbybit.dk/mysqlfaq


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to