You need to sign in to do that
Don't have an account?
How to get data from Parent table and child table?
Hello,everyone:
Now, I want to get some datas fromtwo tables(parent and child table).the question is blow:
[
Relationship:Parent to child
.......
SOQL is this:select a.Id,a.Name,a.Industry,(Select c.Id,c.FirstName,c.LastName From a.Contacts c)
From Account a;
and I can get some datas(a.Id,a.Name,a.Industry) of "Account" table, and I use blew codes to access the "Contact" object,but qr always is null,why? How can I do?
[
for (int i = 0; i < qr.records.Length; i++)
{
account = (Account)qr.records[i];
QueryResult qr = account.Contacts;
.......
}
]
Relationship:Child to Parent
.......
SOQL is this:Select Id, FirstName,MailingCity from Contact where Account.Name like '%a%'
.......
for (int i = 0; i < qr.records.Length; i++)
{
contact = (Contact)qr.records[i];
Account acc = (Account)contact.Account;
here, acc alwasy is null,I don't know how to do?
}
]
Who can give me some advises or a completely example of getting datas from two tables(Parent and childe)?
sincerely
skyfj