我正在尝试编写以下查询:
SELECT DISTINCT t.* FROM tasks t WHERE (769, 2) IN
(SELECT c3.id FROM categories c3 JOIN tasks_categories tc ON c3.id = tc.category_id WHERE tc.task_id = t.id)
但它失败了,错误如下:
ERROR: subquery has too few columns
看起来原因是我在检查 (769, 2)
在子查询的结果中。如何重写此查询以检查:
ANY of (769, 2) in the result of (subselect) ?
2条答案
按热度按时间tpgth1q71#
你可以用
exists
. . . 可能不需要select distinct
:dgiusagp2#
你必须用下面的格式重写查询,