gpt4 book ai didi

mysql - SQL - 如果字段有空值,如何创建一个好的查询?

转载 作者:行者123 更新时间:2023-11-29 11:46:50 25 4
gpt4 key购买 nike

我在数据库中有一条这样的记录:

表名:progreen

------------------------
id name proid specid
------------------------
1 A01 1 null
2 A02 19 4
3 A03 6 2
------------------------

我的查询:

如果我这样做select * from progreen where proid = 1 andspecid = null;结果是null,它应该显示第一行。

如果我这样做select * from progreen where proid = 19 andspecid = 4;它运行良好

如果字段具有空值,如何创建良好的查询?

where子句中是否使用sql if语句

最佳答案

从 progreen 中选择 *,其中指定为 NULL

关于mysql - SQL - 如果字段有空值,如何创建一个好的查询?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34784532/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com