我想过滤出一张唱片.
如果statusid为null,则过滤记录(其中statusid不为null)
如果statsid不为空,则过滤查看statusid等于指定stateID的记录.
我该怎么做呢?
我想过滤出一张唱片.
如果statusid为null,则过滤记录(其中statusid不为null)
如果statsid不为空,则过滤查看statusid等于指定stateID的记录.
我该怎么做呢?
就像你说的那样
select * from tbl where statusid is null
或
select * from tbl where statusid is not null
If your statusid is not null, then it will be selected just fine when you have an actual value, no need f或 any "if" logic if that is what you were thinking
select * from tbl where statusid = 123 -- the rec或d(s) returned will not have null statusid
if you want to select where it is null 或 a value, try
select * from tbl where statusid = 123 或 statusid is null