1drop table if exists t1;
2CREATE TABLE t1 (id CHAR(12) not null, PRIMARY KEY (id));
3insert into t1 values ('000000000001'),('000000000002');
4explain select * from t1 where id=000000000001;
5id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
61	SIMPLE	t1	index	PRIMARY	PRIMARY	12	NULL	2	Using where; Using index
7select * from t1 where id=000000000001;
8id
9000000000001
10delete from t1 where id=000000000002;
11select * from t1;
12id
13000000000001
14drop table t1;
15SELECT 'a' = 'a ';
16'a' = 'a '
171
18SELECT 'a\0' < 'a';
19'a\0' < 'a'
201
21SELECT 'a\0' < 'a ';
22'a\0' < 'a '
231
24SELECT 'a\t' < 'a';
25'a\t' < 'a'
261
27SELECT 'a\t' < 'a ';
28'a\t' < 'a '
291
30CREATE TABLE t1 (a char(10) not null);
31INSERT INTO t1 VALUES ('a'),('a\0'),('a\t'),('a ');
32SELECT hex(a),STRCMP(a,'a'), STRCMP(a,'a ') FROM t1;
33hex(a)	STRCMP(a,'a')	STRCMP(a,'a ')
3461	0	0
356100	-1	-1
366109	-1	-1
3761	0	0
38DROP TABLE t1;
39SELECT CHAR(31) = '', '' = CHAR(31);
40CHAR(31) = ''	'' = CHAR(31)
410	0
42SELECT CHAR(30) = '', '' = CHAR(30);
43CHAR(30) = ''	'' = CHAR(30)
440	0
45create table t1 (a tinyint(1),b binary(1));
46insert into t1 values (0x01,0x01);
47select * from t1 where a=b;
48a	b
49Warnings:
50Warning	1292	Truncated incorrect DOUBLE value: '\x01'
51select * from t1 where a=b and b=0x01;
52a	b
53Warnings:
54Warning	1292	Truncated incorrect DOUBLE value: '\x01'
55drop table if exists t1;
56CREATE TABLE  t1 (b int(2) zerofill, c int(2) zerofill);
57INSERT INTO t1 (b,c) VALUES (1,2), (1,1), (2,2);
58SELECT CONCAT(b,c), CONCAT(b,c) = '0101' FROM t1;
59CONCAT(b,c)	CONCAT(b,c) = '0101'
600102	0
610101	1
620202	0
63EXPLAIN EXTENDED SELECT b,c FROM t1 WHERE b = 1 AND CONCAT(b,c) = '0101';
64id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
651	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where
66Warnings:
67Note	1003	select `test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`b` = 1) and (concat('01',`test`.`t1`.`c`) = '0101'))
68SELECT b,c FROM t1 WHERE b = 1 AND CONCAT(b,c) = '0101';
69b	c
7001	01
71CREATE TABLE t2 (a int);
72INSERT INTO t2 VALUES (1),(2);
73SELECT a,
74(SELECT COUNT(*) FROM t1
75WHERE b = t2.a AND CONCAT(b,c) = CONCAT('0',t2.a,'01')) x
76FROM t2 ORDER BY a;
77a	x
781	1
792	0
80EXPLAIN EXTENDED
81SELECT a,
82(SELECT COUNT(*) FROM t1
83WHERE b = t2.a AND CONCAT(b,c) = CONCAT('0',t2.a,'01')) x
84FROM t2 ORDER BY a;
85id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
861	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	2	100.00	Using filesort
872	DEPENDENT SUBQUERY	t1	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where
88Warnings:
89Note	1276	Field or reference 'test.t2.a' of SELECT #2 was resolved in SELECT #1
90Note	1276	Field or reference 'test.t2.a' of SELECT #2 was resolved in SELECT #1
91Note	1003	select `test`.`t2`.`a` AS `a`,(select count(0) from `test`.`t1` where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (concat(`test`.`t1`.`b`,`test`.`t1`.`c`) = concat('0',`test`.`t2`.`a`,'01')))) AS `x` from `test`.`t2` order by `test`.`t2`.`a`
92DROP TABLE t1,t2;
93CREATE TABLE t1 (a TIMESTAMP);
94INSERT INTO t1 VALUES (NOW()),(NOW()),(NOW());
95SELECT * FROM t1 WHERE a > '2008-01-01' AND a = '0000-00-00';
96a
97DROP TABLE t1;
98End of 5.0 tests
99