BeginsWith element (Query)

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

Searches for a string at the start of a column that holds Text or Note field type values.

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

Elements and attributes

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



Child elements

Parent elements


  • Minimum: 0
  • Maximum: Unbounded


The following example uses the BeginsWith element within a string that is assigned to the Query property to return the titles of items within a list where a Journal column begins with "City".

SPWeb mySite = SPControl.GetContextWeb(Context);
SPList list = mySite.Lists["List_Name "];
SPQuery query = new SPQuery();
query.Query = "<Where>" +
                "<BeginsWith>" +
                  "<FieldRef Name="Journal"/>" +
                  "<Value Type="Note">City</Value>" +
                "</BeginsWith>" +
SPListItemCollection myItems = list.GetItems(query);
foreach (SPListItem item in myItems)
   Label1.Text += item["Title"] + "<BR>";

See also