0

can i use lookup to display data extension column value?

I am trying to display name of the email recipient in email if EmailAdd_Column matches with the recipient email address.

In my case the audience data extension of an email is different from the data extension from which I want to pull the value. This is the reason I am thinking about usnig lookup.

I have this ampscript to pull Name but it is not working?

%%[
SET @pullname = LookupRows("DataExtensionName","NameColumn", "EmailAdd_Column", emailaddr)
]%%

Value from NameColumn is %%=v(@pullname)=%%
1

The LookUpRows function is returning a rowset. You should use LookUp for this use case.

You would also have to use IF control for cases where it doesn't match i.e Dear Customer

Example:

%%[

var @pullname , @nullpullname /* It is best practice is always declare your variables */

SET @nullpullname = 'Dear Customer' /* This is just an example to help you see how / why you should add flow control to this */
SET @pullname = Lookup("DataExtensionName","NameColumn", "EmailAdd_Column", emailaddr)

]%%

%%[IF @pullname IS NOT EMPTY THEN]%%

%%=v(@pullname)=%%

%%[ELSE]%%

%%=v(@nullpullname)=%%


%%[ENDIF]%%

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.