The ! symbol in MySQL represents the negation operator, which can be used to: negate Boolean expressions, turning TRUE into FALSE and FALSE into TRUE. Negates a number, but does not change the sign of the number, but negates its boolean value.
The meaning of !
in MySQL
In the MySQL database, ! The
symbol represents the negation operator, which can be used to negate Boolean expressions.
Specific usage
!
Operator can be used to evaluate a Boolean expression Negate the formula. For example, if x
is TRUE
, then !x
is FALSE
. -
symbol can also be used to negate numbers, but this is different from the !
operator. The -
operator inverts a number and produces a negative value, while the !
operator simply inverts the Boolean value of a number. Examples
Here are some examples of using the !
operator:
SELECT * FROM table WHERE name != 'John';
: Select all rows in the table where the name
column is not equal to "John"
. SET x = !x;
: Negate the value of variable x
. IF (!x) { ... };
: If x
is FALSE
, the statements in the block are executed. Note
!
operators have higher precedence than relational operators, so you need to be careful when using them. !
The operator cannot be used alone, it must be used with a Boolean expression or number. The above is the detailed content of What does! in mysql mean?. For more information, please follow other related articles on the PHP Chinese website!