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
cassiecassie 

how to transfer SQL to SOQL

I have SQL query here, can you help to transfer to SOQL?
 
Select o.OpportunityId from OpportunityLineItem o inner join PricebookEntry PE on o.PricebookEntryID=PE.ID inner join Product2 P on PE.product2ID=P.Id where P.Id in
(select Product2.Id from Product2 where Product2.Family  not LIKE 'Service%')
 
Thanks,
 
Cassie
KobeKobe
This should work: Select (select OpportunityId from OpportunityLineItems), p.Product2Id  from PricebookEntry p where not (p.Product2.Family like 'Service%')
hector.asp2hector.asp2

dude not working ,we tried "SELECT Id,AccountId,Name from Contact where not(Name like 'a%')"

 

Arun thakur 

er.arunthakur@gmail.com

KobeKobe

What is not working, query error or incorrect results?

 

When I run your query it appears to run just fine. No contacts starting with the letter A is returned.

AlohaTechAlohaTech

I need help on following soql

 

[SELECT Id, Audience__c, Document_Type__c, Title, Last_Update__c, RatingCount, OwnerId FROM ContentVersion WHERE
                   (isEmpty(:domain) = true OR Domain__c = :domain) AND
                   (isEmpty(:compaign) = true OR Campaign__c = :compaign)];

 

where :domain and :compaign are my member variables of type String. The aim is to appy filter on WHERE clause only if my member variable has value assigned. In case of empty member variable I want pass the check.

 

This gives me error
Error: Compile Error: unexpected token: ':' at line 54 column 28

 

I need somethign like in SQL (@Variable IS NULL OR dbField = @Variable)

 

Please help

 

 

AlohaTechAlohaTech

One more thing I cannot use LIKE operator since the field I am checking is multipicklist field