Hi,
While testing to compare char and varchar, I found a strange result.
Look at the result of the second select statement. ("Oxford ": spaces at the end)
select length (street), concat (‘[’, street, ‘]’) from temp where street = 'Oxford ';
Test procedure summary:
memsql> select @@memsql_version;
+------------------+
| @@memsql_version |
+------------------+
| 7.1.1 |
+------------------+
1 row in set (0.01 sec)
memsql> Create table temp (City CHAR(10), Street VARCHAR(10));
Query OK, 0 rows affected (0.05 sec)
memsql> desc temp;
+--------+-------------+------+------+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+-------------+------+------+---------+-------+
| City | char(10) | YES | | NULL | |
| Street | varchar(10) | YES | | NULL | |
+--------+-------------+------+------+---------+-------+
2 rows in set (0.00 sec)
memsql> Insert into temp values('Pune','Oxford');
Query OK, 1 row affected (0.02 sec)
memsql> Insert into temp values('Pune ','Oxford ');
Query OK, 1 row affected (0.02 sec)
memsql> Insert into temp values('Pune ','Oxford ');
Query OK, 1 row affected (0.00 sec)
memsql> select length(city), length(street), concat('[', street, ']') from temp;
+--------------+----------------+--------------------------+
| length(city) | length(street) | concat('[', street, ']') |
+--------------+----------------+--------------------------+
| 4 | 7 | [Oxford ] |
| 4 | 6 | [Oxford] |
| 4 | 7 | [Oxford ] |
+--------------+----------------+--------------------------+
**memsql> select length(street), concat('[', street, ']') from temp where street='Oxford ';**
**+----------------+--------------------------+**
**| length(street) | concat('[', street, ']') |**
**+----------------+--------------------------+**
**| 7 | [Oxford ] |**
**| 6 | [Oxford] |**
**| 7 | [Oxford ] |**
**+----------------+--------------------------+**
**3 rows in set (0.04 sec)**
memsql> select length(street), concat('[', street, ']') from temp where street='Oxford';
+----------------+--------------------------+
| length(street) | concat('[', street, ']') |
+----------------+--------------------------+
| 6 | [Oxford] |
| 7 | [Oxford ] |
| 7 | [Oxford ] |
+----------------+--------------------------+
3 rows in set (0.00 sec)
memsql> select length(street), concat('[', street, ']') from temp where street like 'Oxford';
+----------------+--------------------------+
| length(street) | concat('[', street, ']') |
+----------------+--------------------------+
| 6 | [Oxford] |
+----------------+--------------------------+
1 row in set (0.03 sec)
memsql> select length(street), concat('[', street, ']') from temp where street like 'Oxford ';
+----------------+--------------------------+
| length(street) | concat('[', street, ']') |
+----------------+--------------------------+
| 7 | [Oxford ] |
| 7 | [Oxford ] |
+----------------+--------------------------+
2 rows in set (0.00 sec)
memsql> select length(street), concat('[', street, ']') from temp where street <> 'Oxford ';
Empty set (0.04 sec)
memsql> select length(street), concat('[', street, ']') from temp where street <> 'Oxford';
Empty set (0.00 sec)
Thanks…