I'm in VB. I was originally using 'and'. I was/am comparing to a number - it seemed that VB was changing the value of bit to a bool when I didn't want it to. bit is defined as a long.
Here's mu current string: strSQL = "SELECT * FROM test WHERE (bit AND 1) = 1" This is returning an empty recordset when it should be returning all the records where bit is an odd number. Remember I have 50 records containing the numbers 1 - 50. Diane -----Original Message----- From: J.R. Pitts [mailto:[EMAIL PROTECTED]] Sent: Wednesday, October 02, 2002 2:04 PM To: [EMAIL PROTECTED] Subject: [wdvltalk] RE: SQL search using bitwise operation? What environment are you in? I just did this in Access/VB and it gave the right results. However in VB, 'AND' is the bitwise op, not &. So maybe you had it right the first time, except that you should have been comparing to a number instead of a bool. Is bit defined as a byte? Integer would probably also work; but if stored as anything else, the bits in bit wouldn't line up right. J.R. -----Original Message----- From: Diane Schips [mailto:[EMAIL PROTECTED]] Sent: Wednesday, October 02, 2002 11:17 AM To: [EMAIL PROTECTED] Subject: [wdvltalk] RE: SQL search using bitwise operation? My current statement is: strSQL = "SELECT * FROM test WHERE (bit & 2) = 2" I have 50 records with bit equaling 1 - 50. Yet the above statement now returns an empty recordset. Maybe my parens are off? Diane -----Original Message----- From: J.R. Pitts [mailto:[EMAIL PROTECTED]] Sent: Wednesday, October 02, 2002 10:55 AM To: [EMAIL PROTECTED] Subject: [wdvltalk] RE: SQL search using bitwise operation? Let me add to my previous answer. You need to use the bitwise and (&) ALSO, you compare to an integer value, not bool. So (bit & 2) would return 2. J.R. -----Original Message----- From: Diane Schips [mailto:[EMAIL PROTECTED]] Sent: Wednesday, October 02, 2002 10:28 AM To: [EMAIL PROTECTED] Subject: [wdvltalk] SQL search using bitwise operation? I want to search through a table returning all records where, say, bit 2 is set. How to I do this? Say I'm concerned with a field called bit. I've tried the following: strSQL = "SELECT * FROM test WHERE (bit AND 2) = true" This doesn't work. What am I doing wrong? Diane ____ � The WDVL Discussion List from WDVL.COM � ____ To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED] Send Your Posts To: [EMAIL PROTECTED] To change subscription settings to the wdvltalk digest version: http://wdvl.internet.com/WDVL/Forum/#sub ________________ http://www.wdvl.com _______________________ You are currently subscribed to wdvltalk as: [EMAIL PROTECTED] To unsubscribe send a blank email to %%email.unsub%% ____ � The WDVL Discussion List from WDVL.COM � ____ To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED] Send Your Posts To: [EMAIL PROTECTED] To change subscription settings to the wdvltalk digest version: http://wdvl.internet.com/WDVL/Forum/#sub ________________ http://www.wdvl.com _______________________ You are currently subscribed to wdvltalk as: [EMAIL PROTECTED] To unsubscribe send a blank email to %%email.unsub%% ____ � The WDVL Discussion List from WDVL.COM � ____ To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED] Send Your Posts To: [EMAIL PROTECTED] To change subscription settings to the wdvltalk digest version: http://wdvl.internet.com/WDVL/Forum/#sub ________________ http://www.wdvl.com _______________________ You are currently subscribed to wdvltalk as: [EMAIL PROTECTED] To unsubscribe send a blank email to %%email.unsub%% ____ � The WDVL Discussion List from WDVL.COM � ____ To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED] Send Your Posts To: [EMAIL PROTECTED] To change subscription settings to the wdvltalk digest version: http://wdvl.internet.com/WDVL/Forum/#sub ________________ http://www.wdvl.com _______________________ You are currently subscribed to wdvltalk as: [EMAIL PROTECTED] To unsubscribe send a blank email to %%email.unsub%% ____ � The WDVL Discussion List from WDVL.COM � ____ To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED] Send Your Posts To: [EMAIL PROTECTED] To change subscription settings to the wdvltalk digest version: http://wdvl.internet.com/WDVL/Forum/#sub ________________ http://www.wdvl.com _______________________ You are currently subscribed to wdvltalk as: [email protected] To unsubscribe send a blank email to [EMAIL PROTECTED]
