当前位置:网站首页>Pit avoidance: description of null values in in and not in SQL
Pit avoidance: description of null values in in and not in SQL
2022-07-07 15:18:00 【1024 questions】
Sql in in and not in There is null Situation of value
1.not in Contained in the null Situation of value
2.in Contained in the null Situation of value
mysql There is a default value but it is still inserted null problem
Sql in in and not in There is null Situation of value1)in The logical rule of is or not in The logical rule of is and
2) Judge null Of sql Statement for is not null perhaps is null
3) When you meet null = null Your judgment is due to the inconformity null The rules of judgment , So the result must be flase
1.not in Contained in the null Situation of valueselect * from A where A.name not in (select B.name from B )
Above not in If B Tabular name When the field has a null value , In any case, the query result of the above statement must be empty
2.in Contained in the null Situation of valueselect * from A where A.name in (select B.name from B )
Above in If B Tabular name When the field has a null value , If A Presence in table name The field also has a null value , Then the query result of the above statement will not display A Null value in table
mysql There is a default value but it is still inserted null problemToday, I found that the value of a column of a corresponding record in the project is null, But the value of this column for this record should not be null.
Check the code and find that there is no assignment to the member variable corresponding to this column when inserting , Even if the database column has a default value , When inserting into the database, it is still inserted null.
mysql The default value of is only in insert It will only take effect if there is no such field in the statement , If insert This field is inserted in the, and the value of this field is null,null Values will be inserted into the table , The default value is now invalid .
stay mybatis In development, a table object is usually inserted directly , All fields in the table will be inserted , So if you want to set the default value , Logic should be written at the business level , Instead of relying on mysql Of default To set the default value .
In addition, try to ensure that the new database should use dynamic sql To operate , This can also avoid the above problems .
The above is personal experience , I hope I can give you a reference , I also hope you can support the software development network .
边栏推荐
- 微信小程序 01
- Stream learning notes
- 【OBS】RTMPSockBuf_Fill, remote host closed connection.
- 防火墙基础之服务器区的防护策略
- Read PG in data warehouse in one article_ stat
- JSON parsing instance (QT including source code)
- Cocoscreator operates spine for animation fusion
- Niuke real problem programming - Day12
- 什么是pv和uv? pv、uv
- CTFshow,信息搜集:web3
猜你喜欢
CTFshow,信息搜集:web2
CTFshow,信息搜集:web3
【服务器数据恢复】戴尔某型号服务器raid故障的数据恢复案例
[make a boat diary] [shapr3d STL format to gcode]
Niuke real problem programming - Day11
拜拜了,大厂!今天我就要去厂里
众昂矿业:萤石继续引领新能源市场增长
Niuke real problem programming - Day12
[data mining] visual pattern mining: hog feature + cosine similarity /k-means clustering
Unity之ASE实现卡通火焰
随机推荐
What is data leakage
最安全的证券交易app都有哪些
Cocoscreator resource encryption and decryption
[deep learning] image hyperspectral experiment: srcnn/fsrcnn
Deformable convolutional dense network for enhancing compressed video quality
Ctfshow, information collection: web4
jacoco代码覆盖率
“百度杯”CTF比赛 2017 二月场,Web:include
[Data Mining] Visual Pattern Mining: Hog Feature + cosinus Similarity / K - means Clustering
Delete a whole page in word
Xiaomi's path of chip self-development
15、文本编辑工具VIM使用
[data mining] visual pattern mining: hog feature + cosine similarity /k-means clustering
Read PG in data warehouse in one article_ stat
PG basics -- Logical Structure Management (locking mechanism -- table lock)
Ctfshow, information collection: Web3
写一篇万字长文《CAS自旋锁》送杰伦的新专辑登顶热榜
【Markdown语法高级】让你的博客更精彩(四:设置字体样式以及颜色对照表)
What are the safest securities trading apps
避坑:Sql中 in 和not in中有null值的情况说明