操作数应包含1列 [英] operand should contain 1 columns

查看:104
本文介绍了操作数应包含1列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SELECT topic_id
FROM phpbb_topics AS t
WHERE t.topic_id IN (
    SELECT p.topic_id, COUNT(p.post_id) AS total_posts
    FROM phpbb_posts AS p
    WHERE p.poster_id = 61640
    GROUP BY p.topic_id
    HAVING t.topic_replies_real = total_posts - 1
);

该查询给我以下错误:

错误代码:1241.操作数应包含1列

Error Code: 1241. Operand should contain 1 column(s)

有什么想法吗?

推荐答案

您不应在子查询的SELECT列表中包含COUNT(p.post_id) AS total_posts. 只是

You shouldn't include COUNT(p.post_id) AS total_posts in SELECT list in your subquery. Just

SELECT topic_id   
FROM phpbb_topics AS t
WHERE t.topic_id IN (
    SELECT p.topic_id --, COUNT(p.post_id) AS total_posts 
    FROM phpbb_posts AS p
    WHERE p.poster_id = 61640
    GROUP BY p.topic_id
    HAVING t.topic_replies_real = COUNT(p.post_id) - 1
);

这篇关于操作数应包含1列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆