Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

How do you do a bitwise compare in select where?



5:45 am on Nov 18, 2010 (gmt 0)

5+ Year Member

Hi All,

I'm trying to select from a table by doing a bitwise compare but it does not work. Here is the sql select statement i have in my php script...

$Mask = implode($aom);

$sql = "SELECT * FROM dbtable WHERE ('".$Mask."' & Code)";

Basically; SELECT * FROM dbtable WHERE ('10100000000000' & Code)

$Mask is a 14 character string of ones and zeros i.e. "10100000000000"

Code is also a 14 character string field in the table similar to $Mask.

I want to do a bitwise compare of $Mask & Code with the "And" operator to test if Bits that are set in both $a and $b are set or true. if so, then get the record.



Like i said, the way i have it does not work. Is it because you can't do a bitwise compare on two strings?

A little help would be appreciated.

Software error:

Can't locate /home/deploy/webmasterworld/code_format-v6.lib in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at decode-post-v6.lib line 27, <THREADDAT> line 3.

For help, please send mail to the webmaster (it@imninjas.com), giving this error message and the time and date of the error.