Do Double Equal Sign exist in MySQL?

MySQLMySQLi Database

There is no double equal sign concept. It can be used to compare two values. If you use double equal sign(==) in MySQL, you will get an error message.

Let us verify the concept is true or not. Declare a variable −

mysql> set @Number=10;
Query OK, 0 rows affected (0.00 sec)

Now, compare the above variable value with 10. If both the values are same then the result will be 1 otherwise 0.

Using double equal sign −

mysql> select 10==@Number;

This will produce the following output i.e. an error −

ERROR 1064 (42000): You have an error in your SQL syntax; 
check the manual that corresponds to your MySQL server version 
for the right syntax to use near '==@Number' at line 1

Let us now change the double equal sign(==) to single equal sign(=) −

mysql> select 10=@Number;

This will produce the following output −

+------------+
| 10=@Number |
+------------+
| 1          |
+------------+
1 row in set (0.00 sec)
raja
Published on 29-Apr-2019 11:20:57
Advertisements