0

I'm attempting to execute a query in Exact Target that I was already anticipating experiencing errors with due to a large number of joins as well as querying the same table multiple times, which I have never done before.

The SQL appears sound according to the browser syntax checker I used, however I'm getting an "Incorrect syntax near the keyword 'OR'." error when I attempt save this in Exact Target.

If anyone could point out what I'm missing it would be greatly appreciated.

SELECT p.Id AS PrefID, p.rC_Bios__Active__c aS PrefActive, p.name AS PrefName, p.rC_Bios__Category__c AS PrefCat, p.rC_Bios__Subcategory__c AS PrefSubCat, p.LastModifiedBy AS PrefLMB, p.CreatedBy AS PrefCB, c.Id AS ConID, c.SierraRise_All__c AS ConSRA, c.SierraRise_Exclusive__cS AS ConEx

FROM rC_Bios__Preference__c_Salesforce p

JOIN Contact_Salesforce c ON c.Id = p.rC_Bios__Contact__c

JOIN kweos__EOCS_Data__c_Salesforce a ON a.kwac__Contact__c = c.Id

JOIN Campaign_Salesforce camp ON camp.Id = a.kwac__Related_Action__c

JOIN Campaign_Salesforce effort ON effort.Id = camp.Effort_Type__c

JOIN Campaign_Salesforce program ON program.Id = camp.Program__c

WHERE c.SierraRise_Exclusive__cS = TRUE  
AND p.rC_Bios__Subcategory__c = 'SierraRise Exclusive'  
AND p.rC_Bios__Active__c = TRUE 
AND (program.Name = 'SR' OR effort.Name = ('4' OR '9'))

1 Answer 1

0

T-SQL booleans can be referenced as either 1 or 0 -- if that's how c.SierraRise_Exclusive__cS and p.rC_Bios__Active__c are defined in your Data Extension.

Also you'll have to use the IN syntax in your last WHERE condition:

SELECT 
p.Id AS PrefID
, p.rC_Bios__Active__c aS PrefActive
, p.name AS PrefName
, p.rC_Bios__Category__c AS PrefCat
, p.rC_Bios__Subcategory__c AS PrefSubCat
, p.LastModifiedBy AS PrefLMB
, p.CreatedBy AS PrefCB
, c.Id AS ConID
, c.SierraRise_All__c AS ConSRA
, c.SierraRise_Exclusive__cS AS ConEx
FROM rC_Bios__Preference__c_Salesforce p
JOIN Contact_Salesforce c ON (c.Id = p.rC_Bios__Contact__c)
JOIN kweos__EOCS_Data__c_Salesforce a ON (a.kwac__Contact__c = c.Id)
JOIN Campaign_Salesforce camp ON (camp.Id = a.kwac__Related_Action__c)
JOIN Campaign_Salesforce effort ON (effort.Id = camp.Effort_Type__c)
JOIN Campaign_Salesforce program ON (program.Id = camp.Program__c)
WHERE c.SierraRise_Exclusive__cS = 1
AND p.rC_Bios__Subcategory__c = 'SierraRise Exclusive'  
AND p.rC_Bios__Active__c = 1 
AND (
  program.Name = 'SR' 
  OR effort.Name in ('4','9')
)

You must log in to answer this question.

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