SQL查询 - 不存在不起作用

问题描述 投票:0回答:3
select *
from text_mining
where  NOT EXISTS (select 1 from history
                  where text_mining.Noun = history.Noun
                    and text_mining.Adjective = history.Adjective)

谁能告诉我这有什么问题这是我的错误谢谢

无法识别的关键字。 (位置35处的“NOT”附近) 无法识别的关键字。 (位置39附近的“EXISTS”) 意外的标记。 (靠近“(”46号位置)

sql mariadb not-exists
3个回答
0
投票

位置35表示关键词'NOT'和ÉXISTS'之间的空格;你的查询应该工作,尝试删除位置35的hiden字符;


0
投票
SELECT  t.*
    FROM  text_mining AS t
    LEFT JOIN  history AS h USING(Nown, Adjective)
    WHERE  h.id IS NULL

history应该有任何一个INDEX(Noun, Adjective)


-1
投票
SELECT * FROM history a
WHERE !EXISTS
(SELECT 1 FROM text_mining b 
WHERE a.Noun = b.Noun AND a.Adjective = b.Adjective)

使用!EXISTS而不是NOT EXISTS

© www.soinside.com 2019 - 2024. All rights reserved.