Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Drupal: DELETE users that match a certain role with MySQLAdmin

Posted on 2010-11-10
6
Medium Priority
?
919 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 2000 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 143

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
By, Vadim Tkachenko. In this article we’ll look at ClickHouse on its one year anniversary.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month12 days, 14 hours left to enroll

971 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