我想从sql表中删除空值。以正常方式我们有这样的语法:
String query = "delete from users where arg1 = ?";
PreparedStatement preparedStmt = conn.prepareStatement(query);
preparedStmt.setInt(1, 3);
我们的查询是这样的语法是什么:
DELETE FROM users
WHERE arg1 IS NULL AND Rel IS NULL AND Arg2 IS NULL;
我尝试了上面提到的带有空值的语法,但它没有用。 感谢。
答案 0 :(得分:1)
绑定变量无法避免在处理is
时需要使用=
运算符而不是null
的事实:
String query = "DELETE FROM users WHERE arg1 IS NULL AND Rel IS NULL AND Arg2 IS NULL";
PreparedStatement preparedStmt = conn.prepareStatement(query);
preparedStmt.executeQuery();