본문 바로가기
Salesforce/Trailhead

[Developer Beginner] Apex Basics & Database | Write SOQL Queries

by proudofch 2021. 3. 19.

 

처음엔 mailingPostalCode에서 에러 나더니 또 되네; 왜 그런담

public class ContactSearch {
    public static List<Contact> searchForContacts(String lastName, String mailingPostalCode) {
        List<Contact> answer = new List<Contact>();
        Contact[] conList = [SELECT ID, Name FROM Contact 
                             WHERE LastName=:lastName AND MailingPostalCode=:mailingPostalCode];
        //lastname = a && mailingPostalCode = b
        //cf. MailingPostalCode
        //return Contact records[] list, including ID and Name fields
        for(Contact c : conList) {
            answer.add(c);
        }
        return answer;
	}
}

댓글