function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Rodolfo CalvoRodolfo Calvo 

Show all contacts from one simple account <query>

Hello team, 
I have this code
String soql = 'SELECT id, firstName, lastName, accountId FROM Contact';
I need to call all contacts from one simple account. 
I tried this: 
 
SELECT firstName, lastName, accountId FROM Contact WHERE accountid = '00000000000000'

This query worked fine, but my issue is calling all contact list from calling the account name: 
For example: I have Account_1, what I only have is the name, we imagine we do not have the ID, how could make this query by calling the name of the account?
I also tried this but there was no succeed.
String soql = 'SELECT id, firstName, lastName, accountId FROM Contact WHERE account.id;
How could I make this query correct? 
Thanks in advance
 
Best Answer chosen by Rodolfo Calvo
Arun KumarArun Kumar
If you directly run the query in Developer c
SELECT id, firstName, lastName, accountId FROM Contact WHERE Account.name =  'Master Account'

onsole try this

All Answers

Rodolfo CalvoRodolfo Calvo
I am sorry Roh, it didn't work... 
It showed me the following error 
Initial term of field expression must be a concrete SObject: String

 
Arun KumarArun Kumar
Hi Rodolfo,

Try below query
String soql = 'SELECT id, firstName, lastName, accountId FROM Contact WHERE Account.name=  \' [YOUR ACCOUNT NAME]\' ';

EXAMPLE:

String soql = 'SELECT id, firstName, lastName, accountId FROM Contact WHERE Account.name=  \'Test Account\' ';
RohRoh
Hello Rodolfo,
Here is another example, try to modify the data in this and use it.

String query = 'Select Name,id,FirstName from Object__c where Name__c =\''+Object.Field__c+'\' limit 1';
 Object = Database.query(query);


PLEASE LIKE THIS ANSWER , IF YOU LIKE IT.

Thanks,
Rohit Alladi
 
Rodolfo CalvoRodolfo Calvo
It showed me this error: 
Unknown error parsing query

At using 
String soql = 'SELECT id, firstName, lastName, accountId FROM Contact WHERE Account.name=  \' [Master Account]\' ';

 
Arun KumarArun Kumar
Hi Rodlfo,

Could you please let me know how you are passing the Account.
Please provide the full code here. so that it will be easy to help you.
Arun KumarArun Kumar
If you directly run the query in Developer c
SELECT id, firstName, lastName, accountId FROM Contact WHERE Account.name =  'Master Account'

onsole try this
This was selected as the best answer
Rodolfo CalvoRodolfo Calvo
Arun. 
Thanks a lot for your answer helped me a lot. 
String soql = 'SELECT id, firstName, lastName, accountId FROM Contact WHERE Account.name = \''+sAccountId_3+'\'';

This was exaclty what I needed!! :D 
Regards! 
 
Arun KumarArun Kumar
Hi Rodolfo,

Nice to hear you, issue solved.

Happy to help :)

Thanks,
Arun
t d 36t d 36
Cotomovies (https://techlogitic.net/cotomovies-app/) it is one of the best app i have ever used to solve this
t d 36t d 36
cyberflix (https://cyberflixtvapp.org/) what a lovely post
geeky flowgeeky flow
Download torrents from 1337x proxy unblocked (https://geekyflow.com/1337x-proxy/)
geeky flowgeeky flow
Robert AtkinsonRobert Atkinson
Download Pure IOS WhatsApp (https://www.technolaty.com/download-ios-whatsapp-for-android/) for Android smartphones for free. Visit https://www.technolaty.com/ for more modded Android applications.
Inspire DogsInspire Dogs
dfasd
geeky flowgeeky flow
This actually helped me out to find the best Indian forum board (https://geekyslug.com/xossip)
Amelie GoldmanAmelie Goldman
I was looking for the aswers too. You guys helped me. Thanks :) . (https://instahackingtool.com/)
 
Tom Johnson 11Tom Johnson 11
This post really helped me alot :) . (https://followersfreeinsta.com/)
alex jordenalex jorden
How To Hack A Kahoot With Kahoot Cheats (https://www.toptrendz.net/how-to-hack-a-kahoot-with-kahoot-cheats/), Kahoot Hacks & Kahoot Codes
Sumit shahSumit shah
Saral Portal Haryana (https://www.hindiupdate.in/saral-portal/): सरल पोर्टल Login & Registration (saralharyana.gov.in)
Sam Watson 10Sam Watson 10
If you want to know how to login to TP link router, then go to tplinklogin (https://tplinkloginz.xyz/) page. 
Raj Singh 93Raj Singh 93
Thanks for solving the issue. 
Raj
thomas tylorethomas tylore
Running a Simple Query (https://theerrorcode.com/)