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
Rakesh SRakesh S 

Query for getting fields from Account and contact

Hi All,

i wrote query like " SELECT FirstName,LastName FROM Contact WHERE IN (SELECT Name, Phone FROM Account)". but not working.

Could you pls write simple query for getting frelds from account and contact using inner query.

Thank you..
Amarjeet ChawlaAmarjeet Chawla
SELECT FirstName,LastName FROM Contact WHERE IN (SELECT Id FROM Account)
Rakesh SRakesh S
The above query getting error like this:

FirstName,LastName FROM Contact WHERE IN (SELECT Id FROM Account)
ERROR at Row:1:Column:46
The left operand '' cannot have more than one level of relationships
could you pls solve this..        Thank you
HI rakesh
  select id,firstname,lastname from contact where accountid in(select id from account) limit 10
check this 
if it works mark it as best answer
Rakesh SRakesh S
Hi Pradeep,
it's working. Could you pls explain, why you should take id field as accountid. Actually it is Account.Id right. 
the following both queries are working. Could u pls explain? when should i use dot(.) operator?
SELECT FROM Contact  And   SELECT accountid FROM Contact