【问题标题】:Select rows where values in two columns not matching the request选择两列中的值与请求不匹配的行
【发布时间】:2021-04-22 10:04:14
【问题描述】:

我需要选择两列值不匹配的所有行

name  |  surname
John  |   Smith
John  |   Colch
John  |   Rak
Emmy  |   Oppo
John  |   Oppo

如何选择名称 Name!=John 和 Surname!=Opp 的所有行,因此它将返回除最后一个条目之外的所有内容,因为当我尝试时

Select * from t where name!='john' and surname!='oppo' 

那么我将失去艾美,因为她的姓氏相同。

【问题讨论】:

    标签: mysql sql select rows


    【解决方案1】:

    我认为你实际上想要OR 逻辑:

    SELECT *
    FROM t
    WHERE name <> 'John' OR surname <> 'Oppo';
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-09-23
      • 1970-01-01
      • 2021-03-28
      • 1970-01-01
      • 2014-05-15
      • 2021-02-22
      • 1970-01-01
      相关资源
      最近更新 更多