I guess you could use the SQL bitwise AND operators for this
You want to get fields 5 and 3 so its

10100 == 20

SELECT *
FROM TABLE
WHERE (FLAGS & 20 = 20)

Gunther

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Thursday, 24 July 2003 3:26 PM
To: CF-Talk
Subject: OT: SQL Query - Testing for bits


Hi All,

It's late and this escapes me.  I've done it before, but my mind is drawing
a blank.

I have a database table that contains a field with bitflags.  All flags off
is 0, all flags on is 255, you get the idea.

What I'm trying to do is query the database table and have it show me all
records where the users have bits 5 and 3 turned on.  Another example would
be, "Show me all users in the database that have bit 6 turned on".

I don't seem to recall exactly how to do it.  I think it's something like
this:

SELECT *
FROM TABLE
WHERE (FLAGS & 6 = 0)

...or something like that.

Any help out there?

-Novak


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.
http://www.cfhosting.com

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to