Wel Wel - 1 year ago 130
SQL Question

Firebird SQL: wildcard % with null values

I have a smallint field that have some record have null values in that field. so when I use % in select only records have any values in that field are displayed.

I want to ask is there any other wild card character I can use to display all records including the ones have nulls ? or I have to use or is null ?

Thanks

Answer Source

You can use COALESCE function to replace NULLs with some predefined value. For example:

SELECT
  *
FROM
  my_table
WHERE
  COALESCE(my_field, -1) = some_value
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download