gpt4 book ai didi

mysql - 操作数应包含 1 列 - MySQL NOT IN

转载 作者:行者123 更新时间:2023-11-29 23:37:58 25 4
gpt4 key购买 nike

SELECT * from campaigns WHERE id not in
(SELECT
e.id_campaign, d.name, d.frequency, d.country, d.referral, d.bid, d.status, COUNT(e.id) AS countcap
FROM campaigns d
LEFT JOIN served e
ON d.id = e.id_campaign
WHERE
d.status = 'Active'
GROUP BY e.id_campaign
HAVING
countcap < d.frequency)

我收到错误“操作数应包含 1 列” - 但我需要 COUNT(e.id)

最佳答案

总是这样:

select *
from campaigns
where id not in (
select id_campaign from (
select e.id_campaign as id_campaign, d.frequency, e.id
from campaigns d left join served e on d.id = e.id_campaign
where d.status = 'Active'
group by e.id_campaign
having count(e.id) < d.frequency
)
)

关于mysql - 操作数应包含 1 列 - MySQL NOT IN,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26317054/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com