gpt4 book ai didi

mysql - 如何修复 'Selecting rows without null or blank value in each column'?

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

我在这里使用此代码时遇到问题:

select *
from toadd
where pcode = '' or pcode is null or
brand = '' or brand is null or
description = '' or description is null;

我正在尝试返回上面列中不包含 null 或空白值的值。

我的问题是:我已将查询编码为仅返回空值或空白值,看看它是否确实有效,然后我将使用基于该查询的删除语句。

但它仍然返回包含填充数据的列,即使我已经说过不显示查询中填充的任何值。

不确定为什么要这样做?

我的所有列类型都设置为 VARCHAR 我将数据与文本和数字混合。

这是我的表格布局:

Table: outerb
Columns:
id int(11) AI PK
pcode varchar(255)
brand varchar(255)
description varchar(255)
size varchar(255)
barcode varchar(255)

这就是目前的样子

enter image description here

这是我的预期结果:

enter image description here

最佳答案

将外部or条件更改为and

     select * from toadd where (pcode = '' or pcode is null) and
( brand = '' or brand is null) and
(description = '' or description is null)

关于mysql - 如何修复 'Selecting rows without null or blank value in each column'?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55569676/

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