我有这个查询
SELECT dcp.discount_campaign_id, CASE WHEN dcp.active = 0
THEN dcp.product_id ELSE (pc.category_id where c.sku_code is NOT NULL)
END as discount_campaign_product
FROM discount_campaign_product dcp
JOIN product_categories pc
ON dcp.product_id = pc.product_id
JOIN categories c
ON pc.category_id = c.category_id
基本上我有3个表连接在一起,分别是Discount_campaign_product dcp,product_categories pc和category c
with dcp.product_id = pc.product_id 和pc.category_id = c.id
所以基本上我想输入大小写,如果dcp.active = 0然后插入dcp.product_id,但是如果active!= 0
然后将pc.category_id where
放入pc.category_id具有c.sku_code NOT NULL
那是我编写的,但是格式错误,如何正确查询?