mysql - 如何计算 SQL 查询的选择谓词的否定?

标签 mysql sql database

我有一个 sql 查询“q”,其形式为:

Select attribute from table1, table2 where  SC;

这里“SC”是q中所有选择谓词的合取

就我而言:SC is balance <1000 and salary >=50000

现在我想计算“NSC”,它是qSC的否定,需要一些帮助。

最佳答案

根据您的帖子,您说i want to calculate "NSC" which is negation of SC和 SC是balance <1000 and salary >=50000

因此,SC 的否定就是 balance >= 1000 and salary < 50000

所以,你可以这样做

Select attribute from table1 where balance >= 1000 and salary < 50000

(或)

Select attribute from table1 
where attribute not in 
( select attribute from table1 
where balance <1000 and salary >=50000 )

关于mysql - 如何计算 SQL 查询的选择谓词的否定?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24096265/

相关文章:

MySQL、MSSql、甲骨文 : When to use which?

mysql - 如何处理从某个表中删除多个对象

php - 数据库中的重复行

mysql - 使用 mysql 行值作为 mysql 运算符

java - 在 NamedParameterJdbcTemplate.batchUpdate 中禁用自动提交

sql - 如何使用TSQL从远程数据库获取数据?

Mysql 左连接 sum() 不返回所有项目

mysql - 如何根据外键在mysql中选择项目

database - 数据库设计/延迟/并发,令人头疼

php - fatal error : Cannot use object of type mysqli_result as array in. ..第 97 行