mysql - Find groups with both validated, unvalidated users -


(Not my real Micek schema, but it indicates what is needed.)

Many people can belong to groups, and groups have many users.

  User: ID INT Verified TINYINT (1) Group: ID INT Name VARCHAR (20) Groups_utter: Group Iid INT user_id INT  

Need to find a valid and unauthorized user (respectively valid being 1 or 0 , respectively), in order to Typical manual maintenance jobs are thousands of users, all are from at least one group, but usually only 2-5 users in a group.

This is a live production server, so I can probably prepare myself a query, but for the last time I tried, it took a few minutes before I killed it. (I'm not one of those superb SQL wizards.) I think I can take the server down for maintenance, but if possible, the question that is done in a second case would be great.

For each user, select all those users with whom Is in the same group. Then select only those users who are valid.

  Select users to leave the UIA groups of groups which include g1 ON = User_ID left Join group_utter_group_id = group_id use user user on user_id = id where u 1.validated = 1 and U2 Valid = 0;  

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -