Logic ports in SQL

Asked

Viewed 303 times

5

Is there a command that represents the logic gate XNOR or NOR in SQL? Something that for example denies XOR output

  • 1

    Which database technology to use?

  • 1

    Most important: in its conception, what are the values of NULL XOR NULL, NULL XOR TRUE, NULL XOR FALSE?

  • I’m using Access even though trying to make a query in SQL mode.

2 answers

5

SQL ANSI '92

Operação                Modelo
XOR                     (a != b)
XNOR                    (a == b)
bitwise XOR             (a OR b) AND NOT (a AND b)
bitwise XNOR            NOT ((a OR b) AND NOT (a AND b))

XOR (or exclusive OR) is the difference operator; XNOR, the equality operator. Thus, direct operations can be simplified.

Microsoft (Transact-SQL), Oracle (PL-SQL)

Operação    Operador    Modelo
XOR         ^           @a ^ @b
XNOR        ^ ^1        @a ^ @b ^ 1

The two Dbms share the same symbol for the logical XOR operator (^).

Source:

^ (Bitwise Exclusive OR) (Transact-SQL)

  • Your answer helped me a lot...no access o de equivalencia é o eqv.

3

You can create the function. If it is two variables (A and B) it is only you obey the law A XOR B = (A' E B) OU (A E B'), where ' symbolizes the denial.
To do XNOR just deny the XOR or use A XNOR B = (A' OU B) E (A OU B')

In SQL would be

A XOR B = (((NOT A) AND B) OR (A AND (NOT B)) 

and

A XNOR B = ((A OR (NOT B)) AND ((NOT A) AND B))

Browser other questions tagged

You are not signed in. Login or sign up in order to post.