Cannot use LIKE or CONTAINS operators in where clause

91 views
Skip to first unread message

Stijn van Lieshout

unread,
Jan 15, 2021, 4:05:21 AM1/15/21
to AdWords API and Google Ads API Forum
I am fetching the google ads api (v6) in my python project. 

The following call returns the expected campaign: 

SELECT
    metrics.clicks
FROM campaign
    WHERE campaign.name = 'abc' 

But when I try to use LIKE I get no results back (whereas I should get them back since the string "abc" contains "a"):

SELECT
    metrics.clicks
FROM campaign
    WHERE campaign.name LIKE 'a' 

I also tried CONTAINS and REGEXP_MATCH without success. Why can I filter by exact match (= operator) while all the others fail?






Stijn van Lieshout

unread,
Jan 15, 2021, 4:19:11 AM1/15/21
to AdWords API and Google Ads API Forum
To add to the above. I can use the LIKE operator for exact match (result: 1 campaign row returned):


SELECT
    metrics.clicks
FROM campaign
    WHERE campaign.name LIKE 'abc' 

Google Ads API Forum Advisor Prod

unread,
Jan 15, 2021, 3:02:50 PM1/15/21
to vanliesh...@gmail.com, adwor...@googlegroups.com

Hi Stijn,

Thanks for reaching out. When you filter a field using LIKE operator, if you use the exact term, it will equal to “=”. To filter the field that contains “a” for example in your case, you are supposed to use “a%” and the % stands for a sequence of characters. Here the % is used as a placeholder for 0 or more characters.

Thanks and regards,
Xiaoming, Google Ads API Team
 

Google Logo
Xiaoming
Google Ads API Team
 


ref:_00D1U1174p._5004Q2B0ZAA:ref
Reply all
Reply to author
Forward
0 new messages