文章详情页
mysql 语法 where 简写?
问题描述
今天碰见一段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语法逻辑操作符:
如果后面的操作数是是0,值为1;如果操作数非0,值为0,NULL特殊处理,即是 NOT NULL为NULL。
上一条:javascript - 用了koa mysql2 一直出现一个error下一条:在mybatis使用mysql的ON DUPLICATE KEY UPDATE语法实现存在即更新应该使用哪个标签?
相关文章:
1. 多选框写进数据库怎么写2. android - 使用listview加载不同item,数据填充错误。3. python3.x - python中的虚拟环境怎样设置一直处于激活状态4. Python获取HTTP请求的状态码(200,404等)5. angular.js - angular js 报错 [$injector:modulerr] 模块注入错误6. 前端需要设置 token的吗?7. boostrap怎么在移动端不显示sidebar?8. python中merge后文件莫名变得非常大9. Python处理Dict生成json10. javascript - 读js权威指南“作为值得函数”产生了疑惑,求释疑
排行榜