Convert this SQL code to adwords PHP

38 views
Skip to first unread message

ken...@blvnp.com

unread,
Jan 5, 2018, 1:54:08 AM1/5/18
to AdWords API Forum
    // Create selector.
    $selector
= new Selector();
    $selector
->setFields(['CampaignId', 'AdGroupId', 'Id', 'Criteria',
       
'CriteriaType', 'Impressions', 'Clicks', 'Cost']);

   
// Use a predicate to filter out paused criteria (this is optional).
    $selector
->setPredicates([
       
new Predicate('Status', PredicateOperator::NOT_IN, ['PAUSED'])]);

The PHP code above produces the SQL code below.

SELECT CampaignId, AdGroupId, Id, Criteria, CriteriaType, QualityScore
FROM CRITERIA_PERFORMANCE_REPORT
WHERE
Status IN [ENABLED, PAUSED] and HasQualityScore='TRUE'

Here is the real question. What if I change the "and" to "or".




Peter Oliquino

unread,
Jan 5, 2018, 2:18:52 AM1/5/18
to AdWords API Forum
Hi Ken,

As seen in this section of our AWQL guide, the OR condition is currently not supported in the AWQL used by the AdWords API in its reports and services. You will need to create a separate request for the records you wish to be included supposedly in the OR condition.

Best regards,
Peter
AdWords API Team

ken...@blvnp.com

unread,
Jan 5, 2018, 10:55:17 AM1/5/18
to AdWords API Forum
Like for example how? 
 
Like this?

$selector->setPredicates([
        new Predicate('Status', PredicateOperator::NOT_IN, ['PAUSED']),
        new Predicate('Status', PredicateOperator::NOT_IN, ['PAUSED']),

Peter Oliquino

unread,
Jan 7, 2018, 10:52:20 PM1/7/18
to AdWords API Forum
Hi Ken,

My recommendation would be that you provide a completely different query and use it on a separate request in order to mimic the query and the results that would be retrieved from your supposed OR condition.

Best regards,
Peter Laurence N. Oliquino
AdWords API Team
Reply all
Reply to author
Forward
0 new messages