今天碰见一段sql 不得其解,求解惑!
一段mysql查询语句:
select * from table where fielda='123' and not '456'
and not
是什么意思?
我自己试了下 select * from table where not '123'
也是可以执行的
该怎么理解?
今天碰见一段sql 不得其解,求解惑!
一段mysql查询语句:
select * from table where fielda='123' and not '456'
and not
是什么意思?
我自己试了下 select * from table where not '123'
也是可以执行的
该怎么理解?
好奇怪的写法。
fielda='123' and not '456'
分解:
fielda='123'
and
not '456'
等价于:
fielda='123' and 0
等价于:
select * from table where 0
(不知道我的优先级对不对)
5 回答3.3k 阅读✓ 已解决
3 回答3.6k 阅读✓ 已解决
2 回答2.8k 阅读✓ 已解决
1 回答2.4k 阅读✓ 已解决
5 回答1.4k 阅读
3 回答1.2k 阅读✓ 已解决
3 回答2k 阅读
MySQL语法逻辑操作符:

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