Hi.

On Wed, Dec 12, 2001 at 02:39:07PM +0000, [EMAIL PROTECTED] wrote:
> Hello
> 
> I've got a problem selecting values that match an option from a SET column.
> 
> My two columns are set up as follows:
> 
>          res_places      SET('North','West','South')
>          res_places_re   SET('Aber','Cardiff','Bangor')
> 
> And I'm currently using the following MySQL query:
> 
>          SELECT * FROM gd_records WHERE (res_places & 3) AND (res_places_re 
> & 1);
> 
> Which turns out very strange resutls.
> 
> What I'm trying to do (in english) is to select records from the database 
> which matches option 3 in SET column res_places AND matches option 1 in SET 
> column res_places_re.
> 
> For some reason my SQL query does not give me the desired results. I know 
> that a record matches both these criteria but yet this omits that record 
> when returning result.
[...]

You used the wrong integer values. The n-th value is represented by
power(n-1, 2), i.e. 1, 2, 4, 8, 16, and so on.

SELECT * FROM gd_records WHERE (res_places & 4) AND (res_places_re & 1);

should work. This is documented here:
http://www.mysql.com/doc/S/E/SET.html

Bye,

        Benjamin.


-- 
[EMAIL PROTECTED]

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to