Gossamer Forum
Home : General : Databases and SQL :

mySQL REGEXP

Quote Reply
mySQL REGEXP
Okay, I have a mySQL database (dstructure) that consists of the DMOZ category structure. I would like to limit SELECT of dstructure.name field (category path - for example, Top/Arts/Animation) to xx number subcats. For example, if end-user selects {Depth} as 1 and the {Top Category} as Arts, then it should produce the following results:

Arts/
Arts/Animation
Arts/Architecture
etc.

I tried this (dynamically built depending on {Depth} which in this example is 1 - Top ignored):

SELECT * FROM `dstructure` WHERE `name` REGEXP CONVERT( _utf8 '^Top/Arts' USING latin1 ) AND `name` REGEXP CONVERT( _utf8 '^(.*)+(/(.*)+)?(/(.*)+)?$' USING latin1 )

...but no good. The mySQL REGEXP is too greedy, and {Depth} is ignored. Easy to see why, but a solution escapes me. Any ideas?



----
Cheers,

Dan
Founder and CEO

LionsGate Creative
GoodPassRobot
Magelln
Subject Author Views Date
Thread mySQL REGEXP dan 13854 Aug 26, 2008, 10:24 AM
Thread Re: [dan] mySQL REGEXP
brewt 13639 Aug 26, 2008, 10:30 AM
Thread Re: [brewt] mySQL REGEXP
dan 13579 Aug 26, 2008, 11:06 AM
Thread Re: [dan] mySQL REGEXP
brewt 13585 Aug 26, 2008, 11:18 AM
Post Re: [brewt] mySQL REGEXP
dan 13452 Aug 26, 2008, 11:27 AM