Skip to content

Latest commit

 

History

History
79 lines (60 loc) · 1.99 KB

contains-element-query.md

File metadata and controls

79 lines (60 loc) · 1.99 KB
titlems.managerms.datems.audiencems.topicms.localizationpriorityapi_nameapi_typems.assetiddescription
Contains element (Query)
soliver
3/9/2015
Developer
reference
medium
Query schema
schema
0eefc273-c539-4d82-84ef-338bb0a2021f
In CAML, searches for a string anywhere within a column that holds Text or Note field type values.

Contains element (Query)

Applies to: SharePoint 2016 | SharePoint Foundation 2013 | SharePoint Online | SharePoint Server 2013

Searches for a string anywhere within a column that holds Text or Note field type values.

<Contains> <FieldRef Name = "Field_Name"/> <Value Type = "Field_Type"/> <XML /> </Contains>

Elements and attributes

The following sections describe attributes, child elements, and parent elements.

Attributes

None

Child elements

Parent elements

Occurrences

  • Minimum: 0
  • Maximum: Unbounded

Example

The following example uses the Contains element within a string that is assigned to the Query property to return the titles of items where the Conference column value begins with "Morning" and contains "discussion session".

SPWebmySite=SPControl.GetContextWeb(Context);SPListlist=mySite.Lists["List_Name"];SPQueryquery=newSPQuery();query.Query="<Where><And><BeginsWith><FieldRef Name="Conference"/>" + "<Value Type="Note">Morning</Value></BeginsWith>"+"<Contains><FieldRef Name="Conference" /><Value Type="Note">discussion session</Value>"+"</Contains></And></Where>";SPListItemCollectionmyItems=list.GetItems(query);foreach(SPListItemiteminmyItems){Label1.Text+=item["Title"]+"<BR>";}

See also

close