1
我試圖在MySQL
的子查詢中使用LIMIT
,但每次運行查詢時我都會得到[42000][1235] This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME sub query'
錯誤。在子查詢中使用限制
我想只得到從子查詢返回的第一個20
ID。
SELECT c.collection_name, t.raw
FROM collections c
JOIN member_of_collection m
ON c.collection_id = m.collection_id
JOIN citations t
ON m.citation_id = t.citation_id
WHERE m.collection_id IN
(
SELECT count(*) FROM collections c
JOIN member_of_collection m
ON c.collection_id = m.collection_id
JOIN citations t
ON t.citation_id = m.citation_id
WHERE length(trim(t.raw)) > 0
AND RIGHT(c.collection_name, length(c.collection_name) - 4) IN (SELECT cat_name from cats_cat)
AND left(t.raw, 3) != '–––'
GROUP BY c.collection_name
ORDER BY count(*) desc
LIMIT 20
);
'極限20'需要在子查詢的旁邊。 –
你爲什麼要比較'collection_id'和'count(*)'值? –