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
mbforcembforce 

Need help in constructing SQL query.

I have created 2 object Student and Course with following fields
 
Student - Student Name, address, DOB, Phone Number, Course joined
Course - Course Name, Start Date , end date, Fees,
 
also created a VisualForce page with four input textbox (Student Name, Course, Start date, End Date)
 
user will enter value in some or all of these boxes and click search button on VF page I want to construct Query which will retrieve data from Student and Course object based on user input

e.g. if user input Student Name as John and Course as SFDC and click search button, query should retrieve details (Student Name, course Name, start date , end date, fees) of all the student with name john and enrolled fo course SFDC
 
Note: Object Student and Object Cource have many to many relationship
I have referred following link but couldnt construct query
 
please help in constructing query / provide syntax of the query.
 
Thanks,
Manish B.
Ashish_SFDCAshish_SFDC
Hi Manish, 

You have to use a SOSL query, 

This has to be done on Only one master Object, which has reference to the look up related Object Field. 

Something like this, 

Find Student Name, course Name, start date , end date, fees FROM Student__c WHERE Name = 'Manish' and Student__r.Course__c.CourseName__c = 'sfdc' ;

Regards,
Ashish