您的位置:首页技术文章
文章详情页

mysql 语法 where 简写?

【字号: 日期:2022-06-11 14:33:53浏览:50作者:猪猪

问题描述

今天碰见一段sql 不得其解,求解惑!

一段mysql查询语句:

select * from table where fielda=’123’ and not ’456’

and not 是什么意思?

我自己试了下 select * from table where not ’123’ 也是可以执行的

该怎么理解?

问题解答

回答1:

好奇怪的写法。

fielda=’123’ and not ’456’

分解:

fielda=’123’andnot ’456’

等价于:

fielda=’123’ and 0

等价于:

select * from table where 0

(不知道我的优先级对不对)

回答2:

MySQL语法逻辑操作符:mysql 语法 where 简写?

如果后面的操作数是是0,值为1;如果操作数非0,值为0,NULL特殊处理,即是 NOT NULL为NULL。

相关文章: