D&C Lug - Home Page
Devon & Cornwall Linux Users' Group

[ Date Index ][ Thread Index ]
[ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] comma separated value string comparisons



On 10 Jul 2003 at 12:04, Simon Waters wrote:

> I'm still trying to understand Peter's answer.... obviously I need
> more practice with replace, so SQL may yet surprise me. 

Documentation never was my strong point..

Basically the aim is to turn one of the seach strings into something 
that  works as an argument to the regexp based like that MySQL 
has.
The inner replace escapes the "+" signs as they have a special 
meaning to rlike.
The next replace strips spaces and the outer on swaps the commas 
for "|" symbols giving a nice little regexp.

I haven't used regexps much in either PHP or MySQL but must 
confess to having overindulged a bit in PERL.

Personally I would go for the PHP solution as I think it would be most 
maintainable. I would only use the SQL hack if there was no other 
way.

Cheers,

Pete.

SELECT "PHP, XML, GnuPG, standards, design"
RLIKE REPLACE ( 
 REPLACE ( 
  REPLACE ( 'C++,Perl ,PHP ,networking,security','+','[+]'),
 ' ',''),
',','|') 


--
The Mailing List for the Devon & Cornwall LUG
Mail majordomo@xxxxxxxxxxxx with "unsubscribe list" in the
message body to unsubscribe.


Lynx friendly