2

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?

dixienormous
  • 117
  • 1
  • 4
  • 12

2 Answers2

13

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.

Ashish Gaur
  • 2,030
  • 2
  • 18
  • 32
  • 1
    You should explicitely mention that the `~` operator is Postgres specific. It is not a standard SQL operator. –  Aug 30 '13 at 12:11
  • Thanks. Which DBMS supports the `Status = ~Status` expression? Never seen that. –  Aug 30 '13 at 12:23
0

All SQL server versions after 2014 supports '~' operator, its bitwise not operator. I use it mostly to invert value of some flags (bit columns) in my DB. You can see more here.

Stanic
  • 1
  • 2