当前位置:网站首页>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 .
边栏推荐
- asp. Netnba information management system VS development SQLSERVER database web structure c programming computer web page source code project detailed design
- Mathematical modeling -- what is mathematical modeling
- Zhiting doesn't use home assistant to connect Xiaomi smart home to homekit
- Unity's ASE achieves full screen sand blowing effect
- Stream learning notes
- CTFshow,信息搜集:web1
- Ctfshow, information collection: web9
- A need to review all the knowledge, H5 form is blocked by the keyboard, event agent, event delegation
- CPU与chiplet技术杂谈
- buffer overflow protection
猜你喜欢

Used by Jetson AgX Orin canfd

Apache多个组件漏洞公开(CVE-2022-32533/CVE-2022-33980/CVE-2021-37839)
![[server data recovery] data recovery case of raid failure of a Dell server](/img/5d/03bc8dcc6e554273b34a78c49a9eaf.jpg)
[server data recovery] data recovery case of raid failure of a Dell server

居然从408改考自命题!211华北电力大学(北京)

With 8 modules and 40 thinking models, you can break the shackles of thinking and meet the thinking needs of different stages and scenes of your work. Collect it quickly and learn it slowly

Ctfshow, information collection: web2

2. 堆排序『较难理解的排序』

【服务器数据恢复】某品牌StorageWorks服务器raid数据恢复案例
MongoD管理数据库的方法介绍

CTFshow,信息搜集:web5
随机推荐
Read PG in data warehouse in one article_ stat
Ctfshow, information collection: web4
【深度学习】图像超分实验:SRCNN/FSRCNN
知否|两大风控最重要指标与客群好坏的关系分析
[target detection] yolov5 Runtong voc2007 data set
Spatiotemporal deformable convolution for compressed video quality enhancement (STDF)
Unity's ASE realizes cartoon flame
Ctfshow, information collection: web9
Niuke real problem programming - day16
Write a ten thousand word long article "CAS spin lock" to send Jay's new album to the top of the hot list
Window环境下配置Mongodb数据库
@ComponentScan
Win10 or win11 taskbar, automatically hidden and transparent
[server data recovery] data recovery case of raid failure of a Dell server
Ctfshow, information collection: Web3
【服务器数据恢复】某品牌StorageWorks服务器raid数据恢复案例
Used by Jetson AgX Orin canfd
STM32F103C8T6 PWM驱动舵机(SG90)
Novel Slot Detection: A Benchmark for Discovering Unknown Slot Types in the Dialogue System
Ctfshow, information collection: web8