You need to sign in to do that
Don't have an account?

I have two queries i need to combine and show in single query using 'like' in soql
Hi All,
I have two queries find it as follows:
String partid; String proId; id ProcessId = ApexPages.currentPage().getParameters().get('id'); proId = [select id,part__c,part_id__c from process_sheet__c where id=:ProcessId].Id; partid = [select id,part__c,part_id__c from process_sheet__c where id=:ProcessId].part_id__c ; att=[Select a.Id,a.ContentType,a.ParentId,a.Parent.Type,a.Parent.Name,a.BodyLength From Attachment a where a.parent.Id=:partid ]; attch = [Select a.Id,a.ContentType,a.ParentId,a.Parent.Type,a.Parent.Name,a.BodyLength From Attachment a where a.parent.Id=:proId ];Now I need a result where parent.Id matches with both proId and partid. Please help me!!!
Thanks in advance
try this one
All Answers
Please find the below.
FinalQuery = [Select a.Id,a.ContentType,a.ParentId,a.Parent.Type,a.Parent.Name,a.BodyLength From Attachment a where a.parent.Id=:proId AND a.parent.Id=:partid];
Hope this helps..!!
I tried that, its not working! Can you help something with 'Like'??
try this one
Are you getting any error ? What does part_id__c contains ? I guess it should contain the process_sheet__c record ID right ?
Thanks for your response. Its working now!
In your shared code you are using 2 SOQL query in line 4 and 5, whereas you can use one SOQL query insted of 2.
Also in line 6 and 7 you are fatching same result with same object field, so you can not use AND cluse in WHERE.
Try my below code and let me know is it working for you or not.
Hope this will help you. Let me know if it helped or you need any more assistance.
Please mark this is as the solution if it solved your purpose.
Thanks,
Sohan Raj Gupta