当前位置:网站首页>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 .
边栏推荐
- Niuke real problem programming - Day10
- [data mining] visual pattern mining: hog feature + cosine similarity /k-means clustering
- CTFshow,信息搜集:web10
- 众昂矿业:萤石继续引领新能源市场增长
- 2.Golang基础知识
- CTFshow,信息搜集:web13
- Unity's ASE achieves full screen sand blowing effect
- Guangzhou Development Zone enables geographical indication products to help rural revitalization
- A need to review all the knowledge, H5 form is blocked by the keyboard, event agent, event delegation
- Qu'est - ce qu'une violation de données
猜你喜欢
Protection strategy of server area based on Firewall
【数据挖掘】视觉模式挖掘:Hog特征+余弦相似度/k-means聚类
智汀不用Home Assistant让小米智能家居接入HomeKit
【跟着江科大学Stm32】STM32F103C8T6_PWM控制直流电机_代码
Novel Slot Detection: A Benchmark for Discovering Unknown Slot Types in the Dialogue System
什么是数据泄露
Cocoscreator operates spine for animation fusion
CTFshow,信息搜集:web2
Niuke real problem programming - day14
Ctfshow, information collection: web9
随机推荐
[understanding of opportunity -40]: direction, rules, choice, effort, fairness, cognition, ability, action, read the five layers of perception of 3GPP 6G white paper
2022年5月互联网医疗领域月度观察
时空可变形卷积用于压缩视频质量增强(STDF)
Niuke real problem programming - Day9
Niuke real problem programming - day18
写一篇万字长文《CAS自旋锁》送杰伦的新专辑登顶热榜
HW初级流量监控,到底该怎么做
Niuke real problem programming - day15
Read PG in data warehouse in one article_ stat
MongoDB数据库基础知识整理
What is data leakage
Niuke real problem programming - day16
asp. Netnba information management system VS development SQLSERVER database web structure c programming computer web page source code project detailed design
[target detection] yolov5 Runtong voc2007 data set
Connecting FTP server tutorial
Bye, Dachang! I'm going to the factory today
How does the database perform dynamic custom sorting?
摘抄的只言片语
微信小程序 01
Infinite innovation in cloud "vision" | the 2022 Alibaba cloud live summit was officially launched