I'm working with another programmer with a very long list of emails. He sent them to me encrypted, and said I simply need to use aes_decrypt(email, 'passwordsalt') to get them.
I used:
SELECT * FROM mydatabase.emails;
to confirm that i could see the emails (encrypted) in a table. I could. The table consists of three columns: id,email,blank.
However, when I used:
SELECT id, AES_DECRYPT(email,'passwordsalt') AS email, blank FROM mydatabase.emails;
In the column for email all I got was null values. Does anyone know if there is something wrong with my code?
Related
I realized when trying to query a database I have that I needed to go through four different tables in order to retrieve the data I need. Unfortunately, my brain can not comprehend a JOIN query past two tables so I figured I would ask for help here... I would be very grateful if someone more knowledgeable could help me with that.
Basically, I am trying to figure out the email addresses of the contacts that have been contacted by specific addresses through our Email Marketing Automation Platform that is Mautic.
The way it works is that you have a table with all of the leads with an id and an email address.
You then have a table with every email that has been sent and from which address it has been sent but not to which lead it has been sent. Every email as its own id.
To know to which list of leads an email has been sent, I need to look into a third table that links emails' id to lists' id.
Finally, our fourth table is the list of leads' lists. This is how I can know which lead is part of which list.
So the idea is:
From every email id that has been sent under x#gmail.com, match it to the list of lead its been sent to and check for the leads' id that are inside this lead list. Then retrieve the email of each of these leads' id by looking at the leads table.
My end result should be an email address located in a table called 'ma_leads'
As you can see, each contact has an 'id'. 'id' that we can find in the table `ma_lead_lists_leads' under the column name 'lead_id'.
This table also has a column 'leadlist_id' which we are going to find in the table ma_email_list_xref
This table itself has a column named 'email_id' which we can finally find in ma_emails under the column name 'id'.
This table finally has a "from_address" column that is the filter I talked about initially.
I hope it makes sense. I tried a few JOIN statements but I always seem to make mistakes in the first line so I thought I would turn to this community hoping I can get nudged int he right direction.
Thank you for your time. And I'm obviously going to monitor this thread if any question pops up...
I'd use this :
select l.email
from ma_leads l, ma_lead_lists_leads ll, ma_email_list_xref el, ma_emails l
where l.id = ll.lead_id and ll.leadlist_id = el.leadlist_id and el.email_id = e.id and e.from_address = 'yaniss#sweetspotpr.com';
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
I want to use MySQL MATCH AGAINST to search various columns in a table. One of them is the email address field. Now I'm getting results that I really don't understand.
For example, I want to search for every records that holds 'domain.com' in the email address. So with a LIKE, I would do:
SELECT * FROM account WHERE email LIKE '%domain.com%'
With the MATCH AGAINST I woud do
SELECT * FROM account WHERE MATCH(email) AGAINST ('*domain.com*' IN BOOLEAN MODE)
But this returns a lot of crap which is absolutely not has anything to do with 'domain.com'. What am I doing wrong?
Note! I do a match against on several columns, email is just one of it. But this one fails terribly!
I am using MySQL to query a table of customer details called "clients", which includes a column for email addresses called "email". I would like to exclude all email addresses from gmail, hotmail and yahoo. I have tried writing the query (see below for my latest) but I cannot seem to get the use of NOT LIKE correct or find an alternative.
Can someone please help?
MySQL Query:
SELECT name, email
FROM clients
WHERE email NOT LIKE '%gmail%'
OR email NOT LIKE '%hotmail%'
OR email NOT LIKE '%yahoo%'
;
End
P.S. I have searched for existing questions but no luck in finding the answer I need. Apologies if one already exists and I would appreciate you pointing me in the right direction if you find one. I'm a newbie to all of this, as I started learning SQL a few months ago for work.
You were nearly there, just replace the OR's with ANDs
SELECT name, email
FROM clients
WHERE email NOT LIKE '%gmail%' AND email NOT LIKE '%hotmail%' AND email NOT LIKE '%yahoo%';
By using AND it means that every condition needs to be met. Using just OR means that any condition can be true, but because you're also using NOT LIKE as well technically every row will match your conditions.
e.g. a gmail row matches the hotmail and yahoo rules individually and will therefore be returned in the results because of the OR as any rules can be matched.
I am complete newbie when it comes to MySQL. I have done some searching around here and elsewhere, but haven't been able to work out something that I imagine is very simple.
I have an email program that imports fields/columns from a MySQL database for bulk emails.
I am wanting to only import information for users that have a particular value in a particular column in a table.
To import all users I would normally use:
SELECT firstname, email FROM users
I have tried amending this to:
SELECT firstname, email FROM users WHERE group = "test"
where group is the name of the column that I am trying to test against, and test is the value I am searching for. I think this might be close, but it brings up an error.
Could someone put me straight?
I think your problem is that group is a keyword in MySQL. You can use
SELECT firstname, email FROM users WHERE `group` = "test"
Use back ticks to quote field names.