What does <> "~" mean in SQL

dixienormous picture dixienormous · Aug 30, 2013 · Viewed 13.8k times · Source

I have an SP and part of it states this:

    AND t_phlcm.VAT_FG  <>  "~"

Can you explain the <> "~" part? Does tilde (~) has a special meaning in SQL like % does?

Answer

Ashish Gaur picture Ashish Gaur · Aug 30, 2013

This is an example of simple string comparison which says t_phlcm.VAT_FG must not be equal to "~" character.

Although ~ can be used with regular expressions in Postgres like this :

SELECT * FROM table where name ~ '^ABC'

and is more powerful but is not advised as LIKE(~~) is more fast. Please refer this

Generally speaking ~ is used to complement an integer or bit like this:

Update Users Set [Status] = ~[Status] will invert the status of all users.