You need to sign in to do that
Don't have an account?
vamshi Cap
How to fetch the User with email Id condition in SQL
Hi I need to fetch the User records on the basis of email Id using SQL queries. Requirement we have three objects.
1. Service
2. Account
3. Cycle30Account.
I have written a query get the email Id from the cyclec30 Account from the service object whose status is suspend.
SELECT Prepaid80__Email_Address__c FROM Prepaid80__Cycle30Account__c where Prepaid80__Account__c in (SELECT Prepaid80__Account__c From Prepaid80__Service__c WHERE Prepaid80__Status__c = 'DISCONNECTED')
now with these email Id I need to fetch User Ids.
can please some one help.
Vamshi.
If your query return more than one record, you need to store all emails in a list. If it is returning single email, you can directly use that one.
Use below query to fetch user records:
1. For emails in List (variable name: emailList):
List<User> usrLst = [SELECT Id, Name, Email FROM User WHERE Email IN: emailList ];
2. For single record:
List<User> usrLst = [SELECT Id, Name, Email FROM User WHERE Email =: Prepaid80__Cycle30Account__c.Prepaid80__Email_Address__c ];
-Thanks,
TK
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
set<string> emails = new set<string>();
for(Prepaid80__Service__c ps : list){
emails.add(ps.Prepaid80__Email_Address__c );
}
now list<user> userlist = new list<User>([Select id from user where email=:emails]);