You need to sign in to do that
Don't have an account?
santhoshg
List has more than 1 row for assignment Sobject
Hi All
The following SOQL query shows the "List has more than 1 row for assignment Sobject".
PLS help me
list<contact> ct=[select lastname,firstname,account.name,account.industry from contact where Title='salesforce'];
system.debug(ct.lastname);
system.debug(ct.account.name);
system.debug(ct.account.industry);
thanks
santhos
use index in system.debug:
system.debug(ct[0].lastname);
system.debug(ct[0].account.name);
system.debug(ct[0].account.industry);
system.debug(ct[0].lastname); OR
system.debug(ct.get(0).lastname);
Although the error should not be what is displayed here.
You should iterate throw the list:
list<contact> ct=[select lastname,firstname,account.name,account.industry from contact where Title='salesforce'];
for (contact c : ct) {
system.debug(c.lastname);
system.debug(c.account.name);
system.debug(c.account.industry);
}
Regards
Could you give kudos to my reply (click the star), if it helped you?
Thanks,
Hugo