[development] Creative querying

nan wich nan_wich at bellsouth.net
Mon Nov 23 15:31:51 UTC 2009


Brian Vuyk wrote:
> SELECT DISTINCT u.uid, ur.rid FROM {users} u RIGHT JOIN {users_roles} ur ON ur.uid = u.uid WHERE rid = 6 OR rid = 8 OR rid = 5 OR rid = 7 OR rid = 4 GROUP BY uid;

You might find something like this easier to maintain (think about an array, which could also map the levels):
SELECT DISTINCT u.uid, ur.rid FROM {users} u RIGHT JOIN {users_roles} ur ON ur.uid = u.uid WHERE rid IN (6, 8, 5, 7, 4) GROUP BY uid;
 
Nancy E. Wichmann, PMP
Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20091123/3c0552eb/attachment.html 


More information about the development mailing list