请查看以下查询。
SELECT sub_words.idwords, words_inc.idArticle
(
SELECT sub0.idwords, SUBSTRING_INDEX(GROUP_CONCAT(sub1.idwords), ',', 10) AS excl_words, COUNT(sub1.idwords) AS older_words_cnt
FROM words_learned sub0
LEFT OUTER JOIN words_learned sub1
ON sub0.userId = sub1.userId
AND sub0.order < sub1.order
WHERE sub0.userId = 1
GROUP BY sub0.idwords
) sub_words
INNER JOIN words words_inc
ON sub_words.idwords = words_inc.idwords
LEFT OUTER JOIN words words_exc
ON words_inc.idArticle = words_exc.idArticle
AND FIND_IN_SET(words_exc.idwords, sub_words.excl_words)
WHERE words_exc.idwords IS NULL
ORDER BY older_words_cnt
LIMIT 100
这给出了错误
#1064 - 您的SQL语法出错;查看与您的MySQL服务器版本对应的手册,以便在'SELECT sub0.idwords,SUBSTRING_INDEX(GROUP_CONCAT(sub1.idwords),',',10)AS exc'在第3行附近使用正确的语法
我单独检查了子查询,子查询中没有错误!这里发生了什么?
答案 0 :(得分:1)
您错过了from
关键字
SELECT sub_words.idwords, words_inc.idArticle
FROM
( ...