如何通过SQL派生布尔值



我不能updateinsert;我只能CCD_ 3。到目前为止,我拥有的是

SELECT
m.id AS "Customer #", m.email AS "Email", p.purchased AS "Made Purchase"
FROM customer.profile AS m
LEFT JOIN customer.purchased AS p ON p.id = m.id
WHERE p.status = "SUCCESS"
GROUP BY m.id

customer.profile表结构为:

id电子邮件
1@gmail.com
2
3
4
5

我怀疑您想要:

SELECT m.id as customer_number, m.email AS email,
(p.id IS NOT NULL) AS made_purchase
FROM customer.profile m LEFT JOIN
customer.purchased p
ON p.id = m.id AND p.status = 'SUCCESS'
GROUP BY m.id

最新更新