用于计数的子查询返回多于1行

时间:2018-07-11 15:26:57

标签: mysql count

我正在尝试在mysql 5.7上执行以下查询:

SELECT 
    example.id AS id,
    COUNT((
        SELECT DISTINCT example1.id 
            FROM example1 
        WHERE example1.id = example.id
    )) AS counter
FROM example;

我收到错误:subquery returns more than 1 row

实现我想要的计数的正确方法是什么?我需要分别为每行存在的count of example1 example

0 个答案:

没有答案