All CHAR and VARCHAR values in MySQL are compared without regard to any trailing spaces : Char Varchar : Data Types MySQL TUTORIALS


MySQL TUTORIALS » Data Types » Char Varchar »

 

All CHAR and VARCHAR values in MySQL are compared without regard to any trailing spaces


mysql>
mysql> CREATE TABLE myTable (myname CHAR(10), yourname VARCHAR(10));
Query OK, rows affected (0.03 sec)

mysql>
mysql> INSERT INTO myTable VALUES ('Monty ', 'Monty ');
Query OK, row affected (0.01 sec)

mysql>
mysql> SELECT myname = 'Monty  ', yourname = 'Monty  ' FROM myTable;
+--------------------+----------------------+
| myname = 'Monty  ' | yourname = 'Monty  ' |
+--------------------+----------------------+
|                  |                    |
+--------------------+----------------------+
row in set (0.00 sec)

mysql>
mysql> drop table myTable;
Query OK, rows affected (0.02 sec)

mysql>
mysql>



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

MySQL TUTORIALS

 Navioo Data Types
» Char Varchar