List:Internals« Previous MessageNext Message »
From:Paul DuBois Date:November 22 2002 6:17pm
Subject:Re: [new feature] compare sets
View as plain text  
At 19:02 +0100 11/22/02, Lucas M. Kalita wrote:
>Would it be possible to add a function that compares two sets
>(mysql set column type).
>Someting like:
>COMPARE_SETS(first_set, second_set)
>The function would return FALSE when in second_set there
>are none of the values of first_set. TRUE would be returned
>when second_set has at least one value of those in first_set.

If you use a bitwise AND operator (&) the result will be non-zero
if there is any overlap, 0 if there isn't, and NULL if either operand
is NULL.  So use first_set & second_set and check the result.

>Example 1:
>first_set = 'a,c,d'
>second_set = 'x,y,z'
>COMPARE_SETS would return false
>Example 2:
>first_set = 'a,c,d'
>second_set = 'x,y,a'
>COMPARE_SETS would return true
>Of course this function can have different behavior, for example:
>- return values that are in first_set and are in second_set
>- return values that are in first_set and are not in second_set (addidtional
>opposite function)
>- return number of values that are in first_set and in second_set
>I have read documentation and I couldn't find any function that would
>allow me to compare two sets. I think this function can be useful and
>would be very easy to implement.

[new feature] compare setsLucas M. Kalita22 Nov
  • Re: [new feature] compare setsPaul DuBois22 Nov