Hi I'm trying to write an SQL query in ET, that will look for subscribers in our master data file, and then build out a data extension to use in some other automations for suppression.

Here is the query that I have written:

FROM [Master Data DE] as b
WHERE  b.syCampusid = '5 or 8'

It doesn't look as though it's finding any data with that query, I'm trying to find all the records where the syCampusid is 5 or 8.


1 Answer 1


You have to separate your or into two separate conditions:

SELECT b.* FROM [Master Data DE] as b WHERE b.syCampusid = '5' or b.syCampusid = '8'

Alternatively, you can use an IN statement to avoid having to write long where clauses:

SELECT b.* FROM [Master Data DE] as b WHERE b.syCampusid in ('5', '8')

I should note I've never used SQL for Marketing Cloud specifically, so I'm just going by what I know of the language in general.

  • I'd like to extend Adam's answer by recommending that you don't use the * wildcard specifier to return all fields, but instead define each field name as I've noticed that there are some performance issues when using wildcard specifiers in Marketing Cloud, probably due to the way the database is indexed. Also, as you are only retrieving from a single DE, you can simply abbreviate your query to read: SELECT field1, field2, field3 FROM [Master Data DE] WHERE syCampusid in ('5', '8') Apr 28, 2016 at 17:33
  • To extend on @Eliot Harper 's answer (I couldn't resist) if it is used only for suppression, you really only need to pull the email address, so you only really need to pull one field from it. Apr 28, 2016 at 18:01
  • Thanks guys! You're awesome, knew I could count on you! The biggest issue once I got this written properly is that the person who set up the "resulting" data extension set the majority of the fields as non-nullable, and therefore it would run, but the DE wouldn't populate - if the field from the search was nullable and the new DE's field wasn't it was breaking. So lesson learned, do all my own DE's from now on, LOL! May 3, 2016 at 16:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .