我想隔离一些带有特定标题的电子邮件。我可以在where子句中使用多个与OR关联的“ like”。这给了我很多结果。但是,如果我尝试在('____','____'等)中执行____,则代码突然不返回任何内容。
这不起作用。
select DATE_TRUNC(DATE(send_time,"America/Los_Angeles"), week(monday)) as week,
status,
settings_title,
sum(emails_sent) as emails_sent,
sum(report_summary_opens) as report_summary_opens,
sum(report_summary_unique_opens) as report_summary_unique_opens,
sum(report_summary_subscriber_clicks) as report_summary_subscriber_clicks
from mailchimp.campaigns_view
where status = 'sent'
and settings_title in ('%_LL_%', '%_IC_%', '%_AC_%', '%_CC_%', '%_PC_%')
group by 1,2,3
order by 1 desc
但是,这可行。
select DATE_TRUNC(DATE(send_time,"America/Los_Angeles"), week(monday)) as week,
status,
settings_title,
sum(emails_sent) as emails_sent,
sum(report_summary_opens) as report_summary_opens,
sum(report_summary_unique_opens) as report_summary_unique_opens,
sum(report_summary_subscriber_clicks) as report_summary_subscriber_clicks
from mailchimp.campaigns_view
where status = 'sent'
and (settings_title like '%_LL_%'
or settings_title like '%_IC_%'
or settings_title like '%_AC_%'
or settings_title like '%_CC_%'
or settings_title like '%_PC_%')
group by 1,2,3
order by 1 desc
我已经尝试在“来自”中包含一个子查询,以消除所有空的settings_title。任何想法为什么这不起作用?我是否缺少一些小的语法错误?
感谢您的帮助!
答案 0 :(得分:2)
%
符号仅与LIKE
一起使用。对于IN
,这只是平等。也尝试REGEXP_CONTAINS
。
如:
SELECT REGEXP_CONTAINS("abcdefg", '(xxx|zzz|yyy|cd)')