LookupRows()
Retrieves a rowset from a data extension.
This function returns a maximum of 2,000 rows. To specify the number of rows returned and the order that rows are returned in, use the LookupOrderedRows() function instead.
LookupRows(1, 2, 3)
Ordinal | Type | Description |
---|---|---|
1 | string | Required. The name of the data extension. |
2 | string or array | Required. The name of the column that contains the data to look up. To specify multiple column names, place the column names in an array. When you specify multiple column names, they’re connected using AND logic. |
3 | string or array | Required. The value to look up in the specified column. To specify multiple values, place the values in an array. If you specify an array for ordinal 2, you must specify an array of equal length for this ordinal. |
To use the function, specify the name of the data extension, the column that contains the data that you want to retrieve and the value to search for in the specified column.
These examples reference a data extension that contains the customer data listed in this table.
ExternalId | FirstName | LastName | PreferredLanguage | RewardsTier |
---|---|---|---|---|
66057f8f-2003-4d08-8c87-b0a16a60d34e | Carolyn | Baumgartner | German | Silver |
be22021f-69ff-4b5c-99c3-bb42193343bc | Ernesto | Rondán | Spanish | Platinum |
e67e755d-d2b9-4a0e-8103-eee7958ef257 | Calvin | Green | English | Silver |
3b7e5138-75c6-4a2b-9155-598c6121d3ea | Tarō | Yamada | Japanese | Gold |
97b40dbb-2eaa-4880-9636-1639f92318a8 | Anna | Kowalski | Polish | Silver |
f86b8f65-6167-4faa-8b0c-8019e389982a | Mindy | Lee | English | Gold |
This example retrieves the value of the PreferredLanguage
column for the row in which the value of the ExternalId
column is 'e67e755d-d2b9-4a0e-8103-eee7958ef257'.
The function outputs English
.
You can also specify multiple values for the column name or the value by placing the values in an array. Multiple values are connected using AND logic. This example retrieves the names of customers whose PreferredLanguage
is English and whose RewardsTier
is Gold.
The function outputs the name of the only customer who meets both criteria: Mindy Lee.