LookupRowsCS()

Returns an unordered rowset from a data extension. The function can return a rowset with up to 2,000 rows. This function is case-sensitive.

AMPscript includes several variations of the LookupRowsCS() function.

  • The LookupRows() function is a case-insensitive version of this function.
  • The LookupOrderedRows() function allows you to specify a column and direction to sort the rowset by.
  • The LookupOrderedRowsCS() function is a case-sensitive version of LookupOrderedRows().

Availability 

Marketing Cloud Engagement ✅ Yes
Marketing Cloud Next ❌ No

Syntax 

1LookupRowsCS(dataExt,
2             searchColumn1, searchValue1,
3             [searchColumn2, searchValue2...])

The LookupRowsCS() function has three parameters.

  • dataExt (string): Required. The name of the data extension that contains the data that you want to retrieve.
  • searchColumn1 (string): Required. The name of the column to search. This value is case-sensitive.
  • searchValue1 (string): Required. The value in the specified column that identifies the rows to retrieve. This value is case-sensitive.

You can optionally append additional search columns and values to the end of the parameter string.

Usage 

This example uses a data extension called “MembershipRewardsProgramme,” which contains the data in this table.

MemberIdFirstNameSurnameRewardsPointsRewardsTierArea
1DennisSmithers923742Chelsea
2PoojaChatterjee2010421Hammersmith
3TomásSantos693113Kensington
4Sun-HiKim239994Twickenham
5JianYeh151234Chelsea

This code retrieves a list of members where the value of the Area column is Chelsea.

1<p>Members in Chelsea:</p>
2<ul>
3%%[
4  Var @membersChelsea, @rowCount
5  Set @membersChelsea = LookupRowsCS("MembershipRewardsProgramme","Area","Chelsea")
6  Set @rowCount = RowCount(@membersChelsea)
7
8  If @rowCount > 0 then
9    For @counter = 1 to @rowCount do
10      Var @row, @memberId, @firstName, @surname, @rewardsPoints
11      Set @row = Row(@membersChelsea, @counter)
12      Set @memberId = Field(@row, "MemberId")
13      Set @firstName = Field(@row, "FirstName")
14      Set @surname = Field(@row, "Surname")
15      Set @rewardsPoints = Field(@row, "RewardsPoints")
16]%%
17  <li>%%=v(@firstName)=%% %%=v(@surname)=%% (member ID %%=v(@memberId)=%%) - Point balance: %%=v(@rewardsPoints)=%%</li>
18%%[
19      Next @counter
20  EndIf
21]%%
22</ul>

The code example outputs an unordered list of results.

1Members in Chelsea:
2
3  • Dennis Smithers (member ID 1) - Point balance: 92374
4  • Jian Yeh (member ID 5) - Point balance: 15123

See Also