Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我试图找到一个解决方案:
我需要选择所有任务的查询,这些任务不是started和此任务的类似任务名称不应该在此表中重复 5 行并带有标志started
started
我的查询:
SELECT * FROM tasks as t WHERE started = 0 AND ((SELECT COUNT(*) FROM tasks WHERE started = 1 AND taskname = taskname) < 5)
但查询不起作用。谁能告诉我我做错了什么?
尝试以下
AND taskname = t.taskname
你非常接近:
SELECT * FROM tasks as t WHERE started = 0 AND (SELECT COUNT(*) FROM tasks WHERE started = 1 AND taskname = t.taskname) < 5
您只需要比较计数结果而不是在子查询中包含比较。t.此外,您需要使用前缀将任务名限定为外部表
t.