当前位置:网站首页>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 - day16
- 一个需求温习到的所有知识,h5的表单被键盘遮挡,事件代理,事件委托
- Niuke real problem programming - day13
- "Baidu Cup" CTF competition 2017 February, web:include
- 【兰州大学】考研初试复试资料分享
- Summer safety is very important! Emergency safety education enters kindergarten
- Niuke real problem programming - Day17
- HW初级流量监控,到底该怎么做
- Yyds dry goods inventory # solve the real problem of famous enterprises: cross line
- Ctfshow, information collection: web13
猜你喜欢
CTFshow,信息搜集:web10
简述keepalived工作原理
MongoD管理数据库的方法介绍
【搞船日记】【Shapr3D的STL格式转Gcode】
Unity之ASE实现卡通火焰
Deformable convolutional dense network for enhancing compressed video quality
Promoted to P8 successfully in the first half of the year, and bought a villa!
Typescript release 4.8 beta
CTFshow,信息搜集:web5
如何在opensea批量发布NFT(Rinkeby测试网)
随机推荐
Ctfshow, information collection: web4
How does the database perform dynamic custom sorting?
Pat grade a 1103 integer factorizatio
Ctfshow, information collection: web13
Guangzhou Development Zone enables geographical indication products to help rural revitalization
Window环境下配置Mongodb数据库
广州开发区让地理标志产品助力乡村振兴
【深度学习】语义分割实验:Unet网络/MSRC2数据集
Unity之ASE实现全屏风沙效果
什么是pv和uv? pv、uv
8大模块、40个思维模型,打破思维桎梏,满足你工作不同阶段、场景的思维需求,赶紧收藏慢慢学
【跟着江科大学Stm32】STM32F103C8T6_PWM控制直流电机_代码
[data mining] visual pattern mining: hog feature + cosine similarity /k-means clustering
有一头母牛,它每年年初生一头小母牛。每头小母牛从第四个年头开始,每年年初也生一头小母牛。请编程实现在第n年的时候,共有多少头母牛?
Ctfshow, information collection: Web3
连接ftp服务器教程
"Baidu Cup" CTF competition 2017 February, web:include
Qu'est - ce qu'une violation de données
Discussion on CPU and chiplet Technology
Ctfshow, information collection: web7