如何在完全连接中查找从未匹配的值

数据挖掘 熊猫 大数据 数据库 sql
2022-01-31 21:53:55

你好我已经完成了这个完整的连接查询:

SELECT
  F.date AS Campaign_Date,
  F.Store AS AS Campaign_Store,
  F.IMPRESSIONS,
  F.CLICKS,
  F.SPEND,
  C.Date AS visitors_Date,
  C.ANNEE_MOIS,
  C.ANNEE,
  C.MOIS,
  C.Store AS visitors_Store,
  C.FREQUENTATION_Store
FROM
  `project.campaigns`  F
FULL JOIN
  `proiject.visitors` C
ON (
  C.Store= F.Store
  AND C.Date =F.date
  )

现在,我想撤销那些从未匹配过任何 Campaign_Store 的列 FRQ_Store 的值!换句话说,如何检索在完全连接查询中从未匹配的两列的所有值?

谢谢!

1个回答

您似乎想要的是 NULL 上的左外连接,这将只为您提供左表中与右表不匹配的行:

SELECT    F.Store
FROM      `project.campaigns`  F
LEFT JOIN `project.visitors`   C
ON (
      F.Store = C.Store
  AND F.Date  = C.Date
  )
WHERE C.Store IS NULL

在此处输入图像描述