Does anyone know of an elegant way to determine, within a query, whether 
two arbitrary lists have common element?

I am quite fond of queries using "in", e.g:  select * from A where 23 in 
(A.list)   - where A.list is a comma-separated list of numbers in a 
varchar(255) field.

Now I need something like:  select * from A where (23,43,21,52,74) in 
(A.list) to work - but it doesn't.
(23,42,21,52,74) is a list of credentials that the current user has. 
 (A.list) is the list of acceptable credentials to access the record.  I 
just need to detect a common element.

And I can find no other way to do it other than breaking my user credential 
list into several tests, like:
        select * from A where (23 in (A.list)) or (42 in (A.list)) or (21 in 
(A.list)), etc.

That's what I'm doing now.  But it's not pretty and can generate some 
rather long query strings.  Another alternative would be to do a three way 
join on a user credential table, access control table, and the table A. 
 But that seems wasteful too.

I suppose what I'm looking for is the equivolent of an "intersection" 
operation between two sets.  But I can't use MySql sets because they are 
bit fields that allow only 64 members.  Does anyone know a more efficient 
or elegant way to do this with MySQL?

_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


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