1

My query

SELECT order_id, order_item_id, product_id, date_due, ship_via 
    FROM order_shipment 
    WHERE (product_id LIKE 'PP80403396-502%%' AND ship_via != '');

OR

SELECT order_id, order_item_id, product_id, date_due, ship_via 
    FROM order_shipment 
    WHERE (product_id LIKE 'PP80403396-502%%' AND trim(ship_via) != '');

does not give me any results.

My expectation would be to display to display the results where ship_via field is NULL or is not empty.

Kermit
  • 33,827
  • 13
  • 85
  • 121
user1558426
  • 13
  • 2
  • 8

1 Answers1

0

NULL is not empty string and not not empty string. And the result of comparison is neither true, nor false, it's NULL. You should use COALESCE to test for NULL or empty. Or OR.

Michael Krelin - hacker
  • 138,757
  • 24
  • 193
  • 173