Solved

Drupal: DELETE users that match a certain role with MySQLAdmin

Posted on 2010-11-10
6
873 Views
Last Modified: 2012-05-10
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
0
Comment
Question by:Quevin
6 Comments
 
LVL 3

Expert Comment

by:dnadavis
ID: 34108919
try this
DELETE FROM users   WHERE uid IN (SELECT ur.uid FROM users_roles  WHERE  rid IN (7,5,6))
0
 
LVL 2

Expert Comment

by:mobiusNZ
ID: 34108958
How about

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

0
 

Author Comment

by:Quevin
ID: 34109150
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?
0
 
LVL 3

Accepted Solution

by:
dnadavis earned 500 total points
ID: 34109236
ok you need to delete the record corresponding to the rid 7 in both the tables users and users_roles right.
then you can use this query.
DELETE  u.*,ur.*  FROM users  u,users_roles ur  WHERE  u.uid = ur.uid AND  ur.rid = 7
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 37283995
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
mysql sql statement - SQL INSERT INTO SELECT 11 46
First name pregmatch 11 30
html input clean up 3 32
Mysql Crashing Intermittently 16 47
Loading csv or delimited data files to MySQL database is a very common task frequently questioned about and almost every time LOAD DATA INFILE comes to the rescue. Here we will try to understand some of the very common scenarios for loading data …
Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now