On Tuesday 26 March 2002 3:30 pm, adam nelson wrote:
> It's been a while since I've done this, does anybody remember:
>
>
> If I have 2 tables:
>
> tblPerson (
> iPersonID int
> szPersonDesc varchar
> iPersonType int
> )
>
> tblPersonType (
> iPersonType int
> szPersonType varchar
> )
>
> iPersonType = iPersonType (foreign key between the 2 tables)
>
> iPersonType is a list in the form of 1,2,4,8,16,32,64
>
> so, let's suppose that szPersonType for 8 is lawyer and szPerson type
> for 2 is redhead
>
> a value of iPersonType of 10 would mean redhead lawyer.
>
> I'd like a query that looks for lawyers (ie. iPerson type is any number
> from 8 to 15 or 16+8=32 or 16+8+4=28 or  16+8+1=29 or 16+8+4+2=30 or
> 32+8=40 or 32+8+4=44 ,etc. up to the max(iPersonType))

Use AND.  I forget the SQL syntax for it but in C, you'd do:

if (iPersonType & 8) {
        // yes
} else {
        // no
}

Note that this is different from the && operator.

---------------------------------------------------------------------
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