[SalesForce] SOQl query to compare multiselect picklist with a variable

I have a string field says ServiceSegment = 'A' and a multiselect picklist Service_segment__c ='A;B;C'. I want to write a SOQL query which can compate string field to multiselect picklist.
I tried this and getting error:

list<User> UsersInContext = [Select firstname, lastname, Related_BDE__c, Related_Team__c,Service_Segment__c, id 
                                                            from 
                                                            User 
                                                            where 
                                                            isactive = true 
                                                            AND
                                                            Service_Segment__c.split(';') =: serviceSegment
                                                            AND
                                                            On_Leave__c = false
                                                            order by 
                                                            Related_Team__c asc];

getting error unexpected token (;). please help me to resolve.

Best Answer

Use this syntax:

Service_Segment__c includes (:serviceSegment)

See the Querying Multi-Select Picklists documentation for the detail.

Related Topic