Bulk user delete with same email - mysql

I want to delete all users who have the email address of #trash-mail.com
How can I do that with a SQL? I'm trying this
DELETE from users
WHERE email LIKE %trash-mail.com
But it's not working and I really need to be able to delete mass accounts.

You forgot quotes:
DELETE FROM users
WHERE email LIKE '%trash-mail.com'
See http://www.techonthenet.com/sql/like.php for more information on the LIKE condition.

Related

Create notification for when a customers account details are updated

Is it possible to create a zuora notification for when the customers account details (email, first name, etc.) are updated? Our example usecase is like so:
If the customers email address is updated (either via an API REST request, within zuora, when re-purchasing a product); trigger a notification that sends an email to the customer (the email will say something along the lines of 'Your account details have updated. If this was you please ignore this email'.

Query MySQL database for user names with their email addresses

I'm looking for a way to query all of my users (simple enough) but i need to get specific users back in the results. I'll try explain the best i can below but in short i want to use a list of email addresses as a reference to pull all users matching those email addresses.
Brief overview
I have a wordpress website which i run events from. When people sign up for the events an account is created for them. there is also another table for attendees which links these user profiles to their registrations.
As it is right now i need to get a list of people specific to one event organiser. I thought the best way to do this would be to use their email address from the attendee info and query my wp_users table for the user names.
SELECT display_name
FROM `mydatabase`.`wp_users` WHERE `user_email` LIKE
'myemail#email.com' OR
'mysecondemail#email.com' OR
'mythirdemail#email.com';
I've removed the real email and changed the database name.
What i am trying to achieve is a query that will run through my list of users comparing their email address that i provide to the users in the table and return any of them that match.
As it is right now it returns the first result it finds and stops.
I've got the list of emails ready to go but i am struggling to get this to work.
You need to repeat the column name like this in the where clause
SELECT display_name
FROM `mydatabase`.`wp_users`
WHERE `user_email` = 'myemail#email.com'
OR `user_email` = 'mysecondemail#email.com'
OR `user_email` = 'mythirdemail#email.com'
or use IN()
SELECT display_name
FROM `mydatabase`.`wp_users`
WHERE `user_email` IN ('myemail#email.com', 'my2email#email.com', 'my3email#email.com')
And like is only used when searching with wildcards. For instance
where email like '%#mydomain.com'
so i managed to figure this out a few minutes after posting this.
I didnt fix the initial issue but i managed to find and create a relationship between the two sets of data in Power BI and get the list i needed.
Thanks though.
PhilB

mySQL randomly update column data from existing data

Does anyone know if it is possible or a way to update columns and randomly change the text around or obfuscate it?
I want to batch update email addresses to something random #example.com for my users table.
I have a users table which contains
(id (unique), firstname, email_address (unique)
So thinking
id.firstname#example.com // (e.g 2012.jane#exmaple.com
I know this can easily be done with PHP, but does anyone know a mySQL function that can do this?
This worked.
update users set email = Concat(id,'.',firstname,'#exampe.com')

How to set same email_address to multiple wordpress users from database

I am working on a wordpress/woocommerce site and using a plugin called "Import users from CSV with meta" I have imported a CSV file with 4000 customers. Since some of those customers have multiple accounts and they use the same email address I also used a plugin called "Allow multiple Accounts".
My problem is that 960/4000 users didn't contain an email address.
I would like to add a custom email address example#example.com to all 960 of them from phpMyAdmin.
Could you please help me with the code?
If I try the following I can see all the users that don't have email but I don't know how to modify all of them:
SELECT * FROM `wp_users` WHERE user_email = ''
I would really appreciate your help.
Thanks in advance.
If I understood you correctly, you just need an update:
UPDATE wp_users SET user_email='example#example.com' WHERE user_email=''

the users that insert by importing csv file can't login in in web2py

I insert users into auth_user table with csv file that include two fields username and password.
users have been inserted into auth_user table successfully,but I can't use username and password to login in. the registration_key is null.why the users can't login in?
Thanks!
This was answered here. Answer copied below:
By default, passwords are hashed when inserted into the auth_user table (via a form validator associated with the password field). So, you don't want to do a standard SQL insert of the plain text passwords into the table (not only is that insecure, but subsequent attempts at login will fail because Auth is expecting hashed passwords).
The easiest way to have the hashing done when doing bulk inserts is to loop through the records and insert each one using the .validate_and_insert method. This will run all of the field validators (which will result in the passwords being hashed), and any records that fail validation will simply not be inserted (so, for example, a duplicate username will not be inserted because it will fail validation).
for user in db(db.user).select():
db.auth_user.validate_and_insert(username=user.username, password=user.password)
Although the validation process will automatically reject any duplicate usernames, if you expect a lot of duplicates and want to improve efficiency, you can first select only the non-duplicates from the user table:
users = db(~db.user.username.belongs(db()._select(db.auth_user.username))).select()
for user in users:
db.auth_user.validate_and_insert(username=user.username, password=user.password)
Also, note that by default, the auth_user table does require values in the first_name, last_name, and email fields (and a valid email address is needed for some of the Auth functionality, such as resetting the password). So, you should either plan to fill in those fields as well, or otherwise set their requires attributes to None so validation does not fail. For example:
db.auth_user.first_name.requires = None
Another option is to define a custom auth_user table.