我在mysql插入命令中遇到语法错误,您有什么建议吗?
先感谢您

    insert = "INSERT INTO dbpedia_untyped_instance SELECT resource FROM stat_resource MINUS (SELECT resource FROM dbpedia_types UNION SELECT resource FROM dbpedia_disambiguations)";
    try {
        stmt.execute(insert);
    } catch (SQLException e) {
        System.out.println("Error inserting into untyped instance table");
        e.printStackTrace();
    }

最佳答案

MySQL当前不支持MINUS

解决方法是,可以使用排除联接。

这样的事情将为您工作(另一种选择是使用NOT EXISTS):

SELECT RESOURCE
FROM stat_resource
LEFT OUTER JOIN dbpedia_types
  ON dbpedia_types.resource = stat_resource.resource
LEFT OUTER JOIN dbpedia_disambiguations
  ON dbpedia_disambiguations.resource = stat_resource.resource
WHERE dbpedia_types.resource IS NULL
  AND dbpedia_disambiguations.resource IS NULL

关于mysql - 使用减号插入mysql中的语法错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/42929864/

10-15 21:11