0
Column1  Column2  Column3  Column4  Column5  Column6
NULL    NULL     NULL   NULL     NULL     NULL

我尝试了以下查询:

1.

Delete from tablename where column1 = NULL

2.

Delete from tablename where column1 IS NULL

第二个查询成功完成,但它说 0 行受到影响。

4

3 回答 3

3

is null尝试匹配空值时必须使用特殊语法:

delete from mytable
where Column1 is null
and Column2 is null
and Column3 is null
and Column4 is null
and Column5 is null
and Column6 is null;

任何常规比较null总是错误的,

例如两者Column1 = nullColumn1 != null总是false

于 2012-07-24T02:15:53.520 回答
0

我相信这对您的 rdbms 或等效项应该有效。如果 isnull 函数的返回值等于空字符串,它将删除行。

DELETE FROM tablename
WHERE isnull(Column1, '') = ''
于 2012-07-24T02:26:01.107 回答
0
DELETE FROM table WHERE coalesce(col1,col2,col3,...) IS NULL
于 2012-07-24T02:29:45.263 回答