You need to sign in to do that
Don't have an account?
krishna casukhela 7
clarification on inner join
Hello friends
I am trying to understand inner join , left outer , right outer , anti join on soql queries.
I have written two queries below, pleae let me know what type of joins they fall in, here's where I have confusion.
How to find all parent records with associated child records?
List<Account> accList=[select Account.Name,(select contact. Name from contacts)
from Account
where ID IN (select AccountID from Contact)];
I want to display those parent records who have orphaned children
List<Account> accList=[select ID, Name from Account
where ID NOT IN (select AccountID from Opportunity
where StageName='Closed Won')];
thanks
krishna
I am trying to understand inner join , left outer , right outer , anti join on soql queries.
I have written two queries below, pleae let me know what type of joins they fall in, here's where I have confusion.
How to find all parent records with associated child records?
List<Account> accList=[select Account.Name,(select contact. Name from contacts)
from Account
where ID IN (select AccountID from Contact)];
I want to display those parent records who have orphaned children
List<Account> accList=[select ID, Name from Account
where ID NOT IN (select AccountID from Opportunity
where StageName='Closed Won')];
thanks
krishna
Following SOQL query returns you all the Accounts and their Contacts. If you want all the Contacts, irrespective of they have an account or not, use the following query.
If you need only the orphan contacts
Hope this helps.
I only want to know the nature of joins used in soql
krishna
also I am not displaying the records in visula force pgae. Just want to understand the type of join used and I know child record is orphan if no parent for it.
If you use the Parent object (for example, Account) as the primary object in the SOQL query, it will act as INNER join and provide you only the children that has a parent.