Thanks !
Glad I asked for some other thoughts on this. I totally over looked this and given how my indexes are setup, this will work much better. Thanks again, Jon -----Original Message----- From: Carsten H. Pedersen [mailto:[EMAIL PROTECTED]] Sent: Sunday, January 13, 2002 11:26 AM To: Jon Shoberg; Beginners (E-mail) Cc: *MySQL mail list Subject: RE: Regexp Help !!! > -----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 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]