Home > Database > Mysql Tutorial > How to write the not equal symbol in mysql

How to write the not equal symbol in mysql

小云云
Release: 2018-01-13 13:41:06
Original
8091 people have browsed it

I want to confirm what symbol is used to represent the inequality operator in mysql. After testing, I found that both <> and != are OK in mysql, but != is not recognized in sqlserver. , so it is recommended to use <>. This article mainly shares with you how to write the mysql not equal symbol. I hope it can help everyone.

selece * from jb51 where id<>45

##The difference between the symbol <> and != in sql

<> and != both mean not equal, but generally use <> to code not equal because <> works in any SQL but != works in sql2000 When used, it is a syntax error, incompatible equals and inequalities in

sql, '=','!=','<>','is null'.. ..Not equal to: <> ,!=,~= ,^= It is said that these four symbols can express inequality in Oracle, but after trying it, I found that <> ,!= ,^= is OK, ~= is not. It should be noted that only <> is the standard SQL syntax and can be transplanted. The others are features of the Oracle platform and have poor portability. Therefore, try to use them during development. <> Indicates not equal to

Equal: = Needless to say, but when you want to judge the equality of null, you must use is null or is not null. Null can only be judged by is null or is not null. , other operators and null operations are all false.

Example, select * from bl_ip_dt where amount <> 800, this statement cannot find the record where amount is equal to null,

select * from bl_ip_dt where amount <> 800 or It's ok if amount is null

MySql's simple query is not equal to NULL

Query the data where aa is null in the table:

select * from table where aa is null;

Query the data in the table where aa is not equal to 1:

select * from table where aa <> 1;

NULL Value Operations:

NULL values ​​may feel strange until you get used to them. Conceptually, NULL means "no value" or "unknown value", and it is treated as a unique value. To test for NULL, you cannot use arithmetic comparison operators such as =, <, or !=. To illustrate it, try the following query:

mysql> SELECT 1 = NULL, 1 <> NULL, 1 < NULL, 1 > NULL;

+------ ---+-----------+----------+----------+
| 1 = NULL | 1 <> ; NULL | 1 < NULL | 1 > NULL |
+----------+-----------+---------- +----------+
| NULL | NULL | NULL | NULL |
+----------+----------- +----------+----------+
Obviously you cannot get meaningful results from these comparisons. Instead use the IS NULL and IS NOT NULL operators:

mysql> SELECT 1 IS NULL, 1 IS NOT NULL;

+-----------+----- ----------+
| 1 IS NULL | 1 IS NOT NULL |
+-----------+---------- -----+
| 0 1 |
+----------+--------------+
Please Note that in MySQL, 0 or NULL means false and any other value means true. The default truth value for Boolean operations is 1.

Self-feeling is null or IFNULL(SUM(),XXX) are often used in development.

In addition, <> and != can be used in php

$a == $b is equal to TRUE, if $a is equal to $b.

$a === $b Congruent TRUE if $a is equal to $b and they are of the same type. (Introduced in PHP 4)
$a != $b not equal TRUE if $a is not equal to $b.
$a <> $b not equal TRUE if $a is not equal to $b.
$a !== $b Not Congruent TRUE if $a is not equal to $b, or their types are different. (Introduced in PHP 4)
$a < $b is less than TRUE if $a is strictly less than $b.
$a > $b is greater than TRUE if $a is strictly $b.
$a <= $b is less than or equal to TRUE if $a is less than or equal to $b.
$a >= $b is greater than or equal to TRUE, if $a is greater than or equal to $b.

Related recommendations:

A brief analysis of the inequality sign in Oracle

php equal to not equal to one exclamation point and two equal signs

mysql not equal to symbol writing

The above is the detailed content of How to write the not equal symbol in mysql. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template