Reputation: 72
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.
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
'[email protected]' OR
'[email protected]' OR
'[email protected]';
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.
Upvotes: 0
Views: 3410
Reputation: 204746
You need to repeat the column name like this in the where
clause
SELECT display_name
FROM `mydatabase`.`wp_users`
WHERE `user_email` = '[email protected]'
OR `user_email` = '[email protected]'
OR `user_email` = '[email protected]'
or use IN()
SELECT display_name
FROM `mydatabase`.`wp_users`
WHERE `user_email` IN ('[email protected]', '[email protected]', '[email protected]')
And like
is only used when searching with wildcards. For instance
where email like '%@mydomain.com'
Upvotes: 1
Reputation: 72
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
Upvotes: 0