Link to home
Start Free TrialLog in
Avatar of Quevin
Quevin

asked on

Drupal: DELETE users that match a certain role with MySQLAdmin

Consider my limited experience with this, and here's the "idea" of what I want to do:

DELETE FROM `users` INNER JOIN `users_roles` ON `users.uid` = `users_roles.uid` WHERE `users_roles.rid` (7, 5, 6);

I don't think that's right, because I get a syntax error, and this is nothing I want to be unsure about, of course.

* MySQL client version: 5.1.41
* Drupal 6.19

Thank you
Avatar of dnadavis
dnadavis
Flag of India image

try this
DELETE FROM users   WHERE uid IN (SELECT ur.uid FROM users_roles  WHERE  rid IN (7,5,6))
Avatar of mobiusNZ
mobiusNZ

How about

DELETE FROM `users` WHERE `users.uid` IN (SELECT `uid` FROM `users_roles` WHERE `rid` = (7, 5, 6))

Avatar of Quevin

ASKER

I ended up deleting each rid:

DELETE FROM drupal.users USING drupal.users INNER JOIN drupal.users_roles ON drupal.users.uid = drupal.users_roles.uid WHERE drupal.users_roles.rid = 7

DELETE FROM drupal.users_roles WHERE drupal.users_roles.rid = 7

Looks like both of the queries would combine this?
ASKER CERTIFIED SOLUTION
Avatar of dnadavis
dnadavis
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Guy Hengel [angelIII / a3]
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.