我有一个与查询相关的问题。我有一个表,其中有一个 hava 这些字段
Table : Videos
Fields : id , video_id , video_title_image_id , video_title_image
现在可以选择使用 video_title_image_id 或 video_title_image 假设 a 有这样的记录
id video_id video_title_image_id video_title_image
1 rSKwjrqBhAA 2 NULL
2 rSKwjrqBhAA NULL image1.png
...
现在我只想选择那些 video_title_image 不为空的 我已经做到了
select video_title_image
from videos
where video_title_image != NULL
但它没有获取任何结果 还有其他选择吗?
最佳答案
这样做:
select video_title_image
from videos
where video_title_image is not NULL
将某些内容与 null
进行比较将导致 unknown
。这就是为什么您需要使用 is
运算符来检查 null
的原因。
关于mysql - 获取同时包含 null 和 not null 的数据库字段非空值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10511005/