Forked from wvpv/sfmc-ampscript-lookup-multiple-column-multiple-ordered-rows.amp
Created
February 6, 2017 18:35
-
-
Save katydorjee/af4f18f59457e9052f4bd6273adc6189 to your computer and use it in GitHub Desktop.
SFMC AMScript Lookup multiple column values from multiple ordered rows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%%[ | |
var @rows, @row, @rowCount, @numRowsToReturn, @lookupValue, @i | |
set @lookupValue = "whee" | |
set @numRowsToReturn = 0 /* 0 means all */ | |
set @rows = LookupOrderedRows("DataExtensionName",@numRowsToReturn,"DEColumn1 desc, DEColumn2 asc","LookupColumn", @lookupValue) | |
set @rowCount = rowcount(@rows) | |
if @rowCount > 0 then | |
for @i = 1 to @rowCount do | |
var @DEColumn1, @DEColumn2 | |
set @row = row(@rows,@i) /*get row based on loop counter */ | |
set @DEColumn1 = field(@row,"DEColumn1") | |
set @DEColumn2 = field(@row,"DEColumn2") | |
]%% | |
Row %%=v(@i)=%%, DEColumn1 is %%=v(@DEColumn1)=%%, DEColumn2 is %%=v(@DEColumn2)=%% | |
%%[ | |
next @i ]%% | |
%%[ else ]%% | |
No rows found | |
%%[ endif ]%% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment