不存在的 MySQL

标签 mysql sql select join

这段代码有什么问题?我不断收到 ERROR 1064 (42000): 你的 SQL 语法有错误

SELECT clientReport.id
  WHERE clientReport.rowNumber NOT EXISTS (
    SELECT clientReport.rowNumber FROM report02, clientReport
      WHERE report02.id=clientReport.id);

最佳答案

我假设你想做这样的事情:

SELECT clientReport.id 
FROM clientReport 
LEFT JOIN report02 ON(report02.id = clientReport.id)
WHERE report02.id is null;

这将从 clientReport 返回所有在 report02 中没有相应条目的 ID。

替代方案可能是:

SELECT clientReport.id FROM clientReport
WHERE clientReport.rowNumber NOT IN (
  SELECT clientReport.rowNumber 
  FROM report02, clientReport
  WHERE report02.id=clientReport.id);

关于不存在的 MySQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5962748/

相关文章:

android - 应用程序Android Json Mysql : Error in http connection android. os.NetworkOnMainThreadException

java - 什么情况下我们需要在数据库中使用组合键

php - 如何获得一个空的关联数组?

SQL 查询 - 坚持使用简单的左连接

sql - 合并连续的日期范围

sql - 计算列 sql 中的寄存器

c - NCurses 聊天行为不当,阻止选择

涉及字节文字的 python 3.4 条件返回 false 而不是 true

mysql - 未检测到最后一个 ID

WHERE 子句中的 mysql SUM()