I want to filter a record....
If statusid is null, filter the record (where statusId is not null)
If statusid is not null, filter the record where statusid is equal to the specified statusid.
How do I do this?
Filtering on your formula After creating the formula for what you want to do, you can filter on the formula column you created in the search bar by typing the value {blank}, {empty}, or {null}, which will act as a filter. Then, you can type normal filter syntax, such as customer name = {empty} or department != {null} .
SQL NULL Filtering for NULL in queries NULL ) will always yield the truth value of UNKNOWN which will be rejected by WHERE . WHERE filters all rows that the condition is FALSE or UKNOWN and keeps only rows that the condition is TRUE .
Below is the syntax to filter the rows without a null value in a specified column. Syntax: SELECT * FROM <table_name> WHERE <column_name> IS NOT NULL; Example: SELECT * FROM demo_orders WHERE ORDER_DATE IS NOT NULL; --Will output the rows consisting of non null order_date values.
Just like you said
select * from tbl where statusid is null
or
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 for any "if" logic if that is what you were thinking
select * from tbl where statusid = 123 -- the record(s) returned will not have null statusid
if you want to select where it is null or a value, try
select * from tbl where statusid = 123 or statusid is null
How about statusid = statusid. Null is never equal to null.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With