MySQL is not equal to symbol _mysql

Source: Internet
Author: User

After testing found in MySQL with <> and!= is OK, but SQL Server does not recognize!=, so it is recommended to use <>

Selece * from jb51 where id<>45

the difference between the symbol <> the!= in SQL

<> and!= are not equal, but generally <> code is not equal to because <> works in any SQL but!= is used in sql2000, it is a syntax error, incompatible

MySQL simple query is not equal to NULL

The data in the query table that AA is null:

SELECT * FROM table where AA is null;

Data in a query table that is not equal to 1:

SELECT * FROM table where AA <> 1;

Null value operation:

A null value can be surprising until you get used to it. Conceptually, null means "no value" or "Unknown value", and it is considered a distinct value. In order to test NULL, you cannot use arithmetic comparison operators such as =, < or!=. To illustrate this, 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 can't get meaningful results from these comparisons. Instead, use is null and are NOT NULL operators:

mysql> SELECT 1 is null, 1 are NOT null;
+-----------+---------------+
| 1 is NULL | 1 is not NULL |
+-----------+---------------+
|             0 | 1 |
+-----------+---------------+
Please note that in MySQL, 0 or null means false and other values mean true. The default truth value of a Boolean operation is 1.

Self-sensing is null or ifnull (SUM (), XXX) is often used in development.

In addition, <> and!= are available in PHP.

$a = = $b equal to TRUE if $a equals $b.
$a = = = $b congruent TRUE if $a equals $b, and they are of the same type. (PHP 4 Introduction)
$a!= $b Unequal TRUE If $a is not equal to $b.
$a <> $b is not equal to TRUE if $a is not equivalent to $b.
$a!== $b are not congruent TRUE if $a is not equal to $b, or they are of different types. (PHP 4 Introduction)
$a < $b small and TRUE if $a are strictly smaller than $b.
$a > $b is greater than TRUE if $a strictly $b.
$a <= $b is less than or equal to TRUE if $a is less than or equal to $b.
$a >= $b greater than or equal to TRUE if $a is greater than or equal to $b.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.