我在SQL中有一列是varchar。我需要它来返回任何有价值的东西。
例如..。
select * from students where StudentID <> ''这样做对吗?我试过不是null,但是它也返回空的任何内容。
谢谢
发布于 2014-10-27 22:43:58
我建议使用聚结:
select * from students where coalesce(StudentID, '') <> ''这将使空字符串变为空字符串,并不允许它们。这也增加了限制空字符串的额外好处。
null不等于任何东西,甚至不等于另一个null,所以简单的<>不能工作。
发布于 2014-10-27 22:44:51
select * from students where StudentID <> '' AND StudentID IS NOT NULL 您可以同时瞄准空白和null。
发布于 2014-10-27 22:42:36
有一种叫“非空”的
SELECT LastName,FirstName,Address FROM Persons WHERE Address IS NOT NULL这有帮助吗?
https://stackoverflow.com/questions/26598056
复制相似问题