[development] Creative querying
Ken Winters
kwinters at coalmarch.com
Mon Nov 23 15:37:06 UTC 2009
On Nov 23, 2009, at 10:18 AM, 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;
>
> Brian
1) Why are you doing a join when all the info you are selecting is in
the users_roles table? If you don't need it for some other reason,
problem solved.
2) I've found it's generally better to use subqueries (where X in
(select Y from Z)) rather than join and group.
- Ken Winters
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20091123/71c9fa6f/attachment.html
More information about the development
mailing list