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
Manoprabha PalpandianManoprabha Palpandian 

Can anyone helpme i have two childobject (Hotel,AirTravel)lookup with Parent-( Registration1). how to write a subquery

Best Answer chosen by Manoprabha Palpandian
CharuDuttCharuDutt
Hii Manoprabha
Try Below Query
Example===> Select Id,Name,(Select Id,Name From Contacts),(Select Id,Name From opportunities) From Account

select id,name,(select id,name from Hotels__r),(select id,name from AirTravels__r) from Registeration1__c

Please Mark It As Best Answer If It Helps
Thank You!

All Answers

CharuDuttCharuDutt
Hii Manoprabha
Try Below Query
Example===> Select Id,Name,(Select Id,Name From Contacts),(Select Id,Name From opportunities) From Account

select id,name,(select id,name from Hotels__r),(select id,name from AirTravels__r) from Registeration1__c

Please Mark It As Best Answer If It Helps
Thank You!
This was selected as the best answer
Manoprabha PalpandianManoprabha Palpandian
thank you charu
CharuDuttCharuDutt

Please Close Your Query By Marking It As Best Answer If It Helps So it Helps Other Also In Future
Thank You!
Manoprabha PalpandianManoprabha Palpandian
I have another doubt in this query how to place it for apex:repeat function
Manoprabha PalpandianManoprabha Palpandian
Registration List || public class Registrationcontroller { public Registration1__c reg1 {get;set;} public String editid {get;set;} public Registrationcontroller() { reg1 = new Registration1__c(); } public List getregisterlist(){ List listreg= new List(); listreg=[SELECT Id, Name, FirstName__c, LastName__c, Email__c FROM Registration1__c]; return listreg; } public void editfunction() { system.debug('editfunction inside===>'+editid); reg1=[SELECT Id, Name, FirstName__c, LastName__c, Email__c FROM Registration1__c where id=:editid]; } public void deletefunction() { system.debug('editfunction inside===>'+editid); List reg2=[SELECT Id, Name, FirstName__c, LastName__c, Email__c FROM Registration1__c where id=:editid]; delete reg2; ApexPages.addMessage(new ApexPages.Message(ApexPages.SEVERITY.INFO,'Record deleted successfully')); } public void saveaction() { system.debug('saveaction inside===>'+reg1); try{ upsert reg1; if(reg1.Id !=null){ ApexPages.addMessage(new ApexPages.Message( ApexPages.SEVERITY.INFO,'Record saved successfully')); reg1=new Registration1__c(); } else { ApexPages.addMessage(new ApexPages.Message(ApexPages.SEVERITY.ERROR,'Record not saved')); } } Catch(Exception e) { System.debug(e.getMessage()); } } }
Manoprabha PalpandianManoprabha Palpandian
please help me
 
CharuDuttCharuDutt
Hii Maoprabha
Try Below Code
public class sample
{   
    public List<Account> acct {get;set;}
    public sample()
    {
        String soql = 'SELECT Name, (SELECT Name, Email FROM Contacts),(Select Id,Name From Opportunities) FROM Account';
        acct = Database.Query(soql);
    }   
}



<apex:page controller="sample">
    <apex:pageBlock >
        <apex:pageBlockTable value="{!acct}" var="a">
            <apex:column value="{!a.Name}"/>
           
            
            <apex:repeat value="{!a.Contacts}" var="c">
                <apex:column value="{!c.Name}"/>
            </apex:repeat>
           
             <apex:repeat value="{!a.Opportunities}" var="d">
                <apex:column value="{!d.Name}"/>
            </apex:repeat>
         
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>

 
Manoprabha PalpandianManoprabha Palpandian
thank you
Manoprabha PalpandianManoprabha Palpandian
Thank you charu it is working but how to give a Hotels and Airtravels Picklist values displayed in the Registration1 record object can you helpme.
Manoprabha PalpandianManoprabha Palpandian
Custom Object - AirTravel, Fields - Arrival and Departure Datatype- Picklist. Custom Object - Hotel, Fields - Check In Date and Check Out Date Datatype- Picklist. These two custom objects lookup with Registraton1__c. How to give Hotels and Airtravel lookupvalues in reagistration1__c. Pls Can you help me.
Manoprabha PalpandianManoprabha Palpandian
please help me charu how to write a coding for that
Manoprabha PalpandianManoprabha Palpandian
please reply my quries