Re: matching an option from SET list
Wiliam Stephens writes: 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. I saw you post this a while back, and at first I couldn't see anything wrong, but then I realized that you probably don't want to match 3 out of 4 values for the first set and every other for the second. That is, you're doing a bitwise AND (), when what you want is probably just a plain equality (=). //C -- Carl Troein - CĂrdan / Istari-PixelMagic - UIN 16353280 [EMAIL PROTECTED] | http://pixelmagic.dyndns.org/~cirdan/ Amiga user since '89, and damned proud of it too. - 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
matching an option from SET list
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. Is the SQL query I am using correct? Is this the correct way of going about what I'm trying to do? I don't want to use FIND_IN_SET because I won't always know the SET option name to pass to FIND_IN_SET. Thanks for your help. Wiliam Stephens Web Developer http://www.fbagroup.co.uk - 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
Re: matching an option from SET list
Hi. On Wed, Dec 12, 2001 at 02:39:07PM +, [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