[ Date Index ][
Thread Index ]
[ <= Previous by date / thread ] [ Next by date / thread => ]
Re: [LUG] comma separated value string comparisons
-----BEGIN PGP SIGNED MESSAGE-----
Neil Williams wrote:
> What's the best way to compare two strings, each containing comma
> values, to see if ANY of the values in the first string match any of the
> values in the second string?
> Ideally, I'd like to do this within an existing SQL query
I fear the SQL way would have had you put each element in a table, and
so now all you would need is a subquery on the table linking whatever
has the attributes to the attributes.
> $string1 = "PHP, XML, GnuPG, standards, design";
> $string2 = "C++, Perl, PHP, networking, security";
> So $string1 should give a match with $string2.
> There are many strings, no predetermined number of values or
> case-requirements. The match must be as wide as possible - the
> to err towards over matching rather than missing just one possible match.
Can you not just turn one string into a series of "like '%$1%' [or] like
'$2%'", it'll over match, but that is as requested.....
I'm still trying to understand Peter's answer.... obviously I need more
practice with replace, so SQL may yet surprise me.
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
-----END PGP SIGNATURE-----
The Mailing List for the Devon & Cornwall LUG
Mail majordomo@xxxxxxxxxxxx with "unsubscribe list" in the
message body to unsubscribe.