1
drop table if exists t1,t2;
3
select 'hello',"'hello'",'""hello""','''h''e''l''l''o''',"hel""lo",'hel\'lo';
4
hello 'hello' ""hello"" 'h'e'l'l'o' hel"lo hel'lo
5
hello 'hello' ""hello"" 'h'e'l'l'o' hel"lo hel'lo
6
select 'hello' 'monty';
9
select length('\n\t\r\b\0\_\%\\');
10
length('\n\t\r\b\0\_\%\\')
12
select bit_length('\n\t\r\b\0\_\%\\');
13
bit_length('\n\t\r\b\0\_\%\\')
15
select char_length('\n\t\r\b\0\_\%\\');
16
char_length('\n\t\r\b\0\_\%\\')
18
select length(_latin1'\n\t\n\b\0\\_\\%\\');
19
length(_latin1'\n\t\n\b\0\\_\\%\\')
21
select concat('monty',' was here ','again'),length('hello'),char(ascii('h')),ord('h');
22
concat('monty',' was here ','again') length('hello') char(ascii('h')) ord('h')
23
monty was here again 5 h 104
24
select hex(char(256));
27
select locate('he','hello'),locate('he','hello',2),locate('lo','hello',2) ;
28
locate('he','hello') locate('he','hello',2) locate('lo','hello',2)
30
select instr('hello','HE'), instr('hello',binary 'HE'), instr(binary 'hello','HE');
31
instr('hello','HE') instr('hello',binary 'HE') instr(binary 'hello','HE')
33
select position(binary 'll' in 'hello'),position('a' in binary 'hello');
34
position(binary 'll' in 'hello') position('a' in binary 'hello')
36
select left('hello',null), right('hello',null);
37
left('hello',null) right('hello',null)
39
select left('hello',2),right('hello',2),substring('hello',2,2),mid('hello',1,5) ;
40
left('hello',2) right('hello',2) substring('hello',2,2) mid('hello',1,5)
42
select concat('',left(right(concat('what ',concat('is ','happening')),9),4),'',substring('monty',5,1)) ;
43
concat('',left(right(concat('what ',concat('is ','happening')),9),4),'',substring('monty',5,1))
45
select substring_index('www.tcx.se','.',-2),substring_index('www.tcx.se','.',1);
46
substring_index('www.tcx.se','.',-2) substring_index('www.tcx.se','.',1)
48
select substring_index('www.tcx.se','tcx',1),substring_index('www.tcx.se','tcx',-1);
49
substring_index('www.tcx.se','tcx',1) substring_index('www.tcx.se','tcx',-1)
51
select substring_index('.tcx.se','.',-2),substring_index('.tcx.se','.tcx',-1);
52
substring_index('.tcx.se','.',-2) substring_index('.tcx.se','.tcx',-1)
54
select substring_index('aaaaaaaaa1','a',1);
55
substring_index('aaaaaaaaa1','a',1)
57
select substring_index('aaaaaaaaa1','aa',1);
58
substring_index('aaaaaaaaa1','aa',1)
60
select substring_index('aaaaaaaaa1','aa',2);
61
substring_index('aaaaaaaaa1','aa',2)
63
select substring_index('aaaaaaaaa1','aa',3);
64
substring_index('aaaaaaaaa1','aa',3)
66
select substring_index('aaaaaaaaa1','aa',4);
67
substring_index('aaaaaaaaa1','aa',4)
69
select substring_index('aaaaaaaaa1','aa',5);
70
substring_index('aaaaaaaaa1','aa',5)
72
select substring_index('aaaaaaaaa1','aaa',1);
73
substring_index('aaaaaaaaa1','aaa',1)
75
select substring_index('aaaaaaaaa1','aaa',2);
76
substring_index('aaaaaaaaa1','aaa',2)
78
select substring_index('aaaaaaaaa1','aaa',3);
79
substring_index('aaaaaaaaa1','aaa',3)
81
select substring_index('aaaaaaaaa1','aaa',4);
82
substring_index('aaaaaaaaa1','aaa',4)
84
select substring_index('aaaaaaaaa1','aaaa',1);
85
substring_index('aaaaaaaaa1','aaaa',1)
87
select substring_index('aaaaaaaaa1','aaaa',2);
88
substring_index('aaaaaaaaa1','aaaa',2)
90
select substring_index('aaaaaaaaa1','1',1);
91
substring_index('aaaaaaaaa1','1',1)
93
select substring_index('aaaaaaaaa1','a',-1);
94
substring_index('aaaaaaaaa1','a',-1)
96
select substring_index('aaaaaaaaa1','aa',-1);
97
substring_index('aaaaaaaaa1','aa',-1)
99
select substring_index('aaaaaaaaa1','aa',-2);
100
substring_index('aaaaaaaaa1','aa',-2)
102
select substring_index('aaaaaaaaa1','aa',-3);
103
substring_index('aaaaaaaaa1','aa',-3)
105
select substring_index('aaaaaaaaa1','aa',-4);
106
substring_index('aaaaaaaaa1','aa',-4)
108
select substring_index('aaaaaaaaa1','aa',-5);
109
substring_index('aaaaaaaaa1','aa',-5)
111
select substring_index('aaaaaaaaa1','aaa',-1);
112
substring_index('aaaaaaaaa1','aaa',-1)
114
select substring_index('aaaaaaaaa1','aaa',-2);
115
substring_index('aaaaaaaaa1','aaa',-2)
117
select substring_index('aaaaaaaaa1','aaa',-3);
118
substring_index('aaaaaaaaa1','aaa',-3)
120
select substring_index('aaaaaaaaa1','aaa',-4);
121
substring_index('aaaaaaaaa1','aaa',-4)
123
select substring_index('the king of thethe hill','the',-2);
124
substring_index('the king of thethe hill','the',-2)
126
select substring_index('the king of the the hill','the',-2);
127
substring_index('the king of the the hill','the',-2)
129
select substring_index('the king of the the hill','the',-2);
130
substring_index('the king of the the hill','the',-2)
132
select substring_index('the king of the the hill',' the ',-1);
133
substring_index('the king of the the hill',' the ',-1)
135
select substring_index('the king of the the hill',' the ',-2);
136
substring_index('the king of the the hill',' the ',-2)
138
select substring_index('the king of the the hill',' ',-1);
139
substring_index('the king of the the hill',' ',-1)
141
select substring_index('the king of the the hill',' ',-2);
142
substring_index('the king of the the hill',' ',-2)
144
select substring_index('the king of the the hill',' ',-3);
145
substring_index('the king of the the hill',' ',-3)
147
select substring_index('the king of the the hill',' ',-4);
148
substring_index('the king of the the hill',' ',-4)
150
select substring_index('the king of the the hill',' ',-5);
151
substring_index('the king of the the hill',' ',-5)
153
select substring_index('the king of the.the hill','the',-2);
154
substring_index('the king of the.the hill','the',-2)
156
select substring_index('the king of thethethe.the hill','the',-3);
157
substring_index('the king of thethethe.the hill','the',-3)
159
select substring_index('the king of thethethe.the hill','the',-1);
160
substring_index('the king of thethethe.the hill','the',-1)
162
select substring_index('the king of the the hill','the',1);
163
substring_index('the king of the the hill','the',1)
165
select substring_index('the king of the the hill','the',2);
166
substring_index('the king of the the hill','the',2)
168
select substring_index('the king of the the hill','the',3);
169
substring_index('the king of the the hill','the',3)
171
select concat(':',ltrim(' left '),':',rtrim(' right '),':');
172
concat(':',ltrim(' left '),':',rtrim(' right '),':')
174
select concat(':',trim(leading from ' left '),':',trim(trailing from ' right '),':');
175
concat(':',trim(leading from ' left '),':',trim(trailing from ' right '),':')
177
select concat(':',trim(LEADING FROM ' left'),':',trim(TRAILING FROM ' right '),':');
178
concat(':',trim(LEADING FROM ' left'),':',trim(TRAILING FROM ' right '),':')
180
select concat(':',trim(' m '),':',trim(BOTH FROM ' y '),':',trim('*' FROM '*s*'),':');
181
concat(':',trim(' m '),':',trim(BOTH FROM ' y '),':',trim('*' FROM '*s*'),':')
183
select concat(':',trim(BOTH 'ab' FROM 'ababmyabab'),':',trim(BOTH '*' FROM '***sql'),':');
184
concat(':',trim(BOTH 'ab' FROM 'ababmyabab'),':',trim(BOTH '*' FROM '***sql'),':')
186
select concat(':',trim(LEADING '.*' FROM '.*my'),':',trim(TRAILING '.*' FROM 'sql.*.*'),':');
187
concat(':',trim(LEADING '.*' FROM '.*my'),':',trim(TRAILING '.*' FROM 'sql.*.*'),':')
189
select TRIM("foo" FROM "foo"), TRIM("foo" FROM "foook"), TRIM("foo" FROM "okfoo");
190
TRIM("foo" FROM "foo") TRIM("foo" FROM "foook") TRIM("foo" FROM "okfoo")
192
select concat_ws(', ','monty','was here','again');
193
concat_ws(', ','monty','was here','again')
194
monty, was here, again
195
select concat_ws(NULL,'a'),concat_ws(',',NULL,'');
196
concat_ws(NULL,'a') concat_ws(',',NULL,'')
198
select concat_ws(',','',NULL,'a');
199
concat_ws(',','',NULL,'a')
201
SELECT CONCAT('"',CONCAT_WS('";"',repeat('a',60),repeat('b',60),repeat('c',60),repeat('d',100)), '"');
202
CONCAT('"',CONCAT_WS('";"',repeat('a',60),repeat('b',60),repeat('c',60),repeat('d',100)), '"')
203
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";"cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc";"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"
204
select insert('txs',2,1,'hi'),insert('is ',4,0,'a'),insert('txxxxt',2,4,'es');
205
insert('txs',2,1,'hi') insert('is ',4,0,'a') insert('txxxxt',2,4,'es')
207
select replace('aaaa','a','b'),replace('aaaa','aa','b'),replace('aaaa','a','bb'),replace('aaaa','','b'),replace('bbbb','a','c');
208
replace('aaaa','a','b') replace('aaaa','aa','b') replace('aaaa','a','bb') replace('aaaa','','b') replace('bbbb','a','c')
209
bbbb bb bbbbbbbb aaaa bbbb
210
select replace(concat(lcase(concat('THIS',' ','IS',' ','A',' ')),ucase('false'),' ','test'),'FALSE','REAL') ;
211
replace(concat(lcase(concat('THIS',' ','IS',' ','A',' ')),ucase('false'),' ','test'),'FALSE','REAL')
213
select soundex(''),soundex('he'),soundex('hello all folks'),soundex('#3556 in bugdb');
214
soundex('') soundex('he') soundex('hello all folks') soundex('#3556 in bugdb')
216
select 'mood' sounds like 'mud';
217
'mood' sounds like 'mud'
219
select 'Glazgo' sounds like 'Liverpool';
220
'Glazgo' sounds like 'Liverpool'
222
select null sounds like 'null';
223
null sounds like 'null'
225
select 'null' sounds like null;
226
'null' sounds like null
228
select null sounds like null;
229
null sounds like null
233
5d41402abc4b2a76b9719d911017c592
239
a9993e364706816aba3e25717850c26c9cd0d89d
242
a9993e364706816aba3e25717850c26c9cd0d89d
243
select aes_decrypt(aes_encrypt('abc','1'),'1');
244
aes_decrypt(aes_encrypt('abc','1'),'1')
246
select aes_decrypt(aes_encrypt('abc','1'),1);
247
aes_decrypt(aes_encrypt('abc','1'),1)
249
select aes_encrypt(NULL,"a");
250
aes_encrypt(NULL,"a")
252
select aes_encrypt("a",NULL);
253
aes_encrypt("a",NULL)
255
select aes_decrypt(NULL,"a");
256
aes_decrypt(NULL,"a")
258
select aes_decrypt("a",NULL);
259
aes_decrypt("a",NULL)
261
select aes_decrypt("a","a");
264
select aes_decrypt(aes_encrypt("","a"),"a");
265
aes_decrypt(aes_encrypt("","a"),"a")
267
select repeat('monty',5),concat('*',space(5),'*');
268
repeat('monty',5) concat('*',space(5),'*')
269
montymontymontymontymonty * *
270
select reverse('abc'),reverse('abcd');
271
reverse('abc') reverse('abcd')
273
select rpad('a',4,'1'),rpad('a',4,'12'),rpad('abcd',3,'12'), rpad(11, 10 , 22), rpad("ab", 10, 22);
274
rpad('a',4,'1') rpad('a',4,'12') rpad('abcd',3,'12') rpad(11, 10 , 22) rpad("ab", 10, 22)
275
a111 a121 abc 1122222222 ab22222222
276
select lpad('a',4,'1'),lpad('a',4,'12'),lpad('abcd',3,'12'), lpad(11, 10 , 22);
277
lpad('a',4,'1') lpad('a',4,'12') lpad('abcd',3,'12') lpad(11, 10 , 22)
278
111a 121a abc 2222222211
279
select rpad(741653838,17,'0'),lpad(741653838,17,'0');
280
rpad(741653838,17,'0') lpad(741653838,17,'0')
281
74165383800000000 00000000741653838
282
select rpad('abcd',7,'ab'),lpad('abcd',7,'ab');
283
rpad('abcd',7,'ab') lpad('abcd',7,'ab')
285
select rpad('abcd',1,'ab'),lpad('abcd',1,'ab');
286
rpad('abcd',1,'ab') lpad('abcd',1,'ab')
288
select rpad('STRING', 20, CONCAT('p','a','d') );
289
rpad('STRING', 20, CONCAT('p','a','d') )
291
select lpad('STRING', 20, CONCAT('p','a','d') );
292
lpad('STRING', 20, CONCAT('p','a','d') )
294
select LEAST(NULL,'HARRY','HARRIOT',NULL,'HAROLD'),GREATEST(NULL,'HARRY','HARRIOT',NULL,'HAROLD');
295
LEAST(NULL,'HARRY','HARRIOT',NULL,'HAROLD') GREATEST(NULL,'HARRY','HARRIOT',NULL,'HAROLD')
297
select least(1,2,3) | greatest(16,32,8), least(5,4)*1,greatest(-1.0,1.0)*1,least(3,2,1)*1.0,greatest(1,1.1,1.0),least("10",9),greatest("A","B","0");
298
least(1,2,3) | greatest(16,32,8) least(5,4)*1 greatest(-1.0,1.0)*1 least(3,2,1)*1.0 greatest(1,1.1,1.0) least("10",9) greatest("A","B","0")
300
select decode(encode(repeat("a",100000),"monty"),"monty")=repeat("a",100000);
301
decode(encode(repeat("a",100000),"monty"),"monty")=repeat("a",100000)
303
select decode(encode("abcdef","monty"),"monty")="abcdef";
304
decode(encode("abcdef","monty"),"monty")="abcdef"
306
select quote('\'\"\\test');
309
select quote(concat('abc\'', '\\cba'));
310
quote(concat('abc\'', '\\cba'))
312
select quote(1/0), quote('\0\Z');
313
quote(1/0) quote('\0\Z')
315
select length(quote(concat(char(0),"test")));
316
length(quote(concat(char(0),"test")))
318
select hex(quote(concat(char(224),char(227),char(230),char(231),char(232),char(234),char(235))));
319
hex(quote(concat(char(224),char(227),char(230),char(231),char(232),char(234),char(235))))
321
select unhex(hex("foobar")), hex(unhex("1234567890ABCDEF")), unhex("345678"), unhex(NULL);
322
unhex(hex("foobar")) hex(unhex("1234567890ABCDEF")) unhex("345678") unhex(NULL)
323
foobar 1234567890ABCDEF 4Vx NULL
324
select hex(unhex("1")), hex(unhex("12")), hex(unhex("123")), hex(unhex("1234")), hex(unhex("12345")), hex(unhex("123456"));
325
hex(unhex("1")) hex(unhex("12")) hex(unhex("123")) hex(unhex("1234")) hex(unhex("12345")) hex(unhex("123456"))
326
01 12 0123 1234 012345 123456
327
select length(unhex(md5("abrakadabra")));
328
length(unhex(md5("abrakadabra")))
330
select concat('a', quote(NULL));
331
concat('a', quote(NULL))
336
select insert("aa",100,1,"b"),insert("aa",1,3,"b"),left("aa",-1),substring("a",1,2);
337
insert("aa",100,1,"b") insert("aa",1,3,"b") left("aa",-1) substring("a",1,2)
339
select elt(2,1),field(NULL,"a","b","c"),reverse("");
340
elt(2,1) field(NULL,"a","b","c") reverse("")
342
select locate("a","b",2),locate("","a",1);
343
locate("a","b",2) locate("","a",1)
345
select ltrim("a"),rtrim("a"),trim(BOTH "" from "a"),trim(BOTH " " from "a");
346
ltrim("a") rtrim("a") trim(BOTH "" from "a") trim(BOTH " " from "a")
348
select concat("1","2")|0,concat("1",".5")+0.0;
349
concat("1","2")|0 concat("1",".5")+0.0
351
select substring_index("www.tcx.se","",3);
352
substring_index("www.tcx.se","",3)
354
select length(repeat("a",100000000)),length(repeat("a",1000*64));
355
length(repeat("a",100000000)) length(repeat("a",1000*64))
358
Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
359
select position("0" in "baaa" in (1)),position("0" in "1" in (1,2,3)),position("sql" in ("mysql"));
360
position("0" in "baaa" in (1)) position("0" in "1" in (1,2,3)) position("sql" in ("mysql"))
363
Warning 1292 Truncated incorrect DOUBLE value: 'baaa'
364
select position(("1" in (1,2,3)) in "01");
365
position(("1" in (1,2,3)) in "01")
367
select length(repeat("a",65500)),length(concat(repeat("a",32000),repeat("a",32000))),length(replace("aaaaa","a",concat(repeat("a",10000)))),length(insert(repeat("a",40000),1,30000,repeat("b",50000)));
368
length(repeat("a",65500)) length(concat(repeat("a",32000),repeat("a",32000))) length(replace("aaaaa","a",concat(repeat("a",10000)))) length(insert(repeat("a",40000),1,30000,repeat("b",50000)))
369
65500 64000 50000 60000
370
select length(repeat("a",1000000)),length(concat(repeat("a",32000),repeat("a",32000),repeat("a",32000))),length(replace("aaaaa","a",concat(repeat("a",32000)))),length(insert(repeat("a",48000),1,1000,repeat("a",48000)));
371
length(repeat("a",1000000)) length(concat(repeat("a",32000),repeat("a",32000),repeat("a",32000))) length(replace("aaaaa","a",concat(repeat("a",32000)))) length(insert(repeat("a",48000),1,1000,repeat("a",48000)))
372
1000000 96000 160000 95000
373
create table t1 ( domain char(50) );
374
insert into t1 VALUES ("hello.de" ), ("test.de" );
375
select domain from t1 where concat('@', trim(leading '.' from concat('.', domain))) = '@hello.de';
378
select domain from t1 where concat('@', trim(leading '.' from concat('.', domain))) = '@test.de';
383
id int(10) unsigned NOT NULL,
384
title varchar(255) default NULL,
385
prio int(10) unsigned default NULL,
386
category int(10) unsigned default NULL,
387
program int(10) unsigned default NULL,
389
created datetime default NULL,
390
modified timestamp NOT NULL,
391
bugstatus int(10) unsigned default NULL,
392
submitter int(10) unsigned default NULL
394
INSERT INTO t1 VALUES (1,'Link',1,1,1,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa','2001-02-28 08:40:16',20010228084016,0,4);
395
SELECT CONCAT('"',CONCAT_WS('";"',title,prio,category,program,bugdesc,created,modified+0,bugstatus,submitter), '"') FROM t1;
396
CONCAT('"',CONCAT_WS('";"',title,prio,category,program,bugdesc,created,modified+0,bugstatus,submitter), '"')
397
"Link";"1";"1";"1";"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";"2001-02-28 08:40:16";"20010228084016";"0";"4"
398
SELECT CONCAT('"',CONCAT_WS('";"',title,prio,category,program,bugstatus,submitter), '"') FROM t1;
399
CONCAT('"',CONCAT_WS('";"',title,prio,category,program,bugstatus,submitter), '"')
400
"Link";"1";"1";"1";"0";"4"
401
SELECT CONCAT_WS('";"',title,prio,category,program,bugdesc,created,modified+0,bugstatus,submitter) FROM t1;
402
CONCAT_WS('";"',title,prio,category,program,bugdesc,created,modified+0,bugstatus,submitter)
403
Link";"1";"1";"1";"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";"2001-02-28 08:40:16";"20010228084016";"0";"4
404
SELECT bugdesc, REPLACE(bugdesc, 'xxxxxxxxxxxxxxxxxxxx', 'bbbbbbbbbbbbbbbbbbbb') from t1 group by bugdesc;
405
bugdesc REPLACE(bugdesc, 'xxxxxxxxxxxxxxxxxxxx', 'bbbbbbbbbbbbbbbbbbbb')
406
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
408
CREATE TABLE t1 (id int(11) NOT NULL auto_increment, tmp text NOT NULL, KEY id (id)) ENGINE=MyISAM;
409
INSERT INTO t1 VALUES (1, 'a545f661efdd1fb66fdee3aab79945bf');
410
SELECT 1 FROM t1 WHERE tmp=AES_DECRYPT(tmp,"password");
414
wid int(10) unsigned NOT NULL auto_increment,
415
data_podp date default NULL,
416
status_wnio enum('nowy','podp','real','arch') NOT NULL default 'nowy',
419
INSERT INTO t1 VALUES (8,NULL,'real');
420
INSERT INTO t1 VALUES (9,NULL,'nowy');
421
SELECT elt(status_wnio,data_podp) FROM t1 GROUP BY wid;
422
elt(status_wnio,data_podp)
426
CREATE TABLE t1 (title text) ENGINE=MyISAM;
427
INSERT INTO t1 VALUES ('Congress reconvenes in September to debate welfare and adult education');
428
INSERT INTO t1 VALUES ('House passes the CAREERS bill');
429
SELECT CONCAT("</a>",RPAD("",(55 - LENGTH(title)),".")) from t1;
430
CONCAT("</a>",RPAD("",(55 - LENGTH(title)),"."))
432
</a>..........................
434
CREATE TABLE t1 (i int, j int);
435
INSERT INTO t1 VALUES (1,1),(2,2);
436
SELECT DISTINCT i, ELT(j, '345', '34') FROM t1;
437
i ELT(j, '345', '34')
441
create table t1(a char(4));
442
insert into t1 values ('one'),(NULL),('two'),('four');
443
select a, quote(a), isnull(quote(a)), quote(a) is null, ifnull(quote(a), 'n') from t1;
444
a quote(a) isnull(quote(a)) quote(a) is null ifnull(quote(a), 'n')
448
four 'four' 0 0 'four'
450
select trim(trailing 'foo' from 'foo');
451
trim(trailing 'foo' from 'foo')
453
select trim(leading 'foo' from 'foo');
454
trim(leading 'foo' from 'foo')
456
select quote(ltrim(concat(' ', 'a')));
457
quote(ltrim(concat(' ', 'a')))
459
select quote(trim(concat(' ', 'a')));
460
quote(trim(concat(' ', 'a')))
462
CREATE TABLE t1 SELECT 1 UNION SELECT 2 UNION SELECT 3;
463
SELECT QUOTE('A') FROM t1;
481
select _latin1'1'=_latin2'1';
482
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation '='
483
select row('a','b','c') = row('a','b','c');
484
row('a','b','c') = row('a','b','c')
486
select row('A','b','c') = row('a','b','c');
487
row('A','b','c') = row('a','b','c')
489
select row('A' COLLATE latin1_bin,'b','c') = row('a','b','c');
490
row('A' COLLATE latin1_bin,'b','c') = row('a','b','c')
492
select row('A','b','c') = row('a' COLLATE latin1_bin,'b','c');
493
row('A','b','c') = row('a' COLLATE latin1_bin,'b','c')
495
select row('A' COLLATE latin1_general_ci,'b','c') = row('a' COLLATE latin1_bin,'b','c');
496
ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT) and (latin1_bin,EXPLICIT) for operation '='
497
select concat(_latin1'a',_latin2'a');
498
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation 'concat'
499
select concat(_latin1'a',_latin2'a',_latin5'a');
500
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (latin2_general_ci,COERCIBLE), (latin5_turkish_ci,COERCIBLE) for operation 'concat'
501
select concat(_latin1'a',_latin2'a',_latin5'a',_latin7'a');
502
ERROR HY000: Illegal mix of collations for operation 'concat'
503
select concat_ws(_latin1'a',_latin2'a');
504
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation 'concat_ws'
505
select FIELD('b','A','B');
508
select FIELD('B','A','B');
511
select FIELD('b' COLLATE latin1_bin,'A','B');
512
FIELD('b' COLLATE latin1_bin,'A','B')
514
select FIELD('b','A' COLLATE latin1_bin,'B');
515
FIELD('b','A' COLLATE latin1_bin,'B')
517
select FIELD(_latin2'b','A','B');
518
ERROR HY000: Illegal mix of collations (latin2_general_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE) for operation 'field'
519
select FIELD('b',_latin2'A','B');
520
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (latin2_general_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE) for operation 'field'
521
select FIELD('1',_latin2'3','2',1);
522
FIELD('1',_latin2'3','2',1)
524
select POSITION(_latin1'B' IN _latin1'abcd');
525
POSITION(_latin1'B' IN _latin1'abcd')
527
select POSITION(_latin1'B' IN _latin1'abcd' COLLATE latin1_bin);
528
POSITION(_latin1'B' IN _latin1'abcd' COLLATE latin1_bin)
530
select POSITION(_latin1'B' COLLATE latin1_bin IN _latin1'abcd');
531
POSITION(_latin1'B' COLLATE latin1_bin IN _latin1'abcd')
533
select POSITION(_latin1'B' COLLATE latin1_general_ci IN _latin1'abcd' COLLATE latin1_bin);
534
ERROR HY000: Illegal mix of collations (latin1_bin,EXPLICIT) and (latin1_general_ci,EXPLICIT) for operation 'locate'
535
select POSITION(_latin1'B' IN _latin2'abcd');
536
ERROR HY000: Illegal mix of collations (latin2_general_ci,COERCIBLE) and (latin1_swedish_ci,COERCIBLE) for operation 'locate'
537
select FIND_IN_SET(_latin1'B',_latin1'a,b,c,d');
538
FIND_IN_SET(_latin1'B',_latin1'a,b,c,d')
540
select FIND_IN_SET(_latin1'B' COLLATE latin1_general_ci,_latin1'a,b,c,d' COLLATE latin1_bin);
541
ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT) and (latin1_bin,EXPLICIT) for operation 'find_in_set'
542
select FIND_IN_SET(_latin1'B',_latin2'a,b,c,d');
543
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation 'find_in_set'
544
select SUBSTRING_INDEX(_latin1'abcdabcdabcd',_latin1'd',2);
545
SUBSTRING_INDEX(_latin1'abcdabcdabcd',_latin1'd',2)
547
select SUBSTRING_INDEX(_latin1'abcdabcdabcd',_latin2'd',2);
548
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation 'substring_index'
549
select SUBSTRING_INDEX(_latin1'abcdabcdabcd' COLLATE latin1_general_ci,_latin1'd' COLLATE latin1_bin,2);
550
ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT) and (latin1_bin,EXPLICIT) for operation 'substring_index'
551
select _latin1'B' between _latin1'a' and _latin1'c';
552
_latin1'B' between _latin1'a' and _latin1'c'
554
select _latin1'B' collate latin1_bin between _latin1'a' and _latin1'c';
555
_latin1'B' collate latin1_bin between _latin1'a' and _latin1'c'
557
select _latin1'B' between _latin1'a' collate latin1_bin and _latin1'c';
558
_latin1'B' between _latin1'a' collate latin1_bin and _latin1'c'
560
select _latin1'B' between _latin1'a' and _latin1'c' collate latin1_bin;
561
_latin1'B' between _latin1'a' and _latin1'c' collate latin1_bin
563
select _latin2'B' between _latin1'a' and _latin1'b';
564
ERROR HY000: Illegal mix of collations (latin2_general_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE) for operation 'between'
565
select _latin1'B' between _latin2'a' and _latin1'b';
566
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (latin2_general_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE) for operation 'between'
567
select _latin1'B' between _latin1'a' and _latin2'b';
568
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE), (latin2_general_ci,COERCIBLE) for operation 'between'
569
select _latin1'B' collate latin1_general_ci between _latin1'a' collate latin1_bin and _latin1'b';
570
ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT), (latin1_bin,EXPLICIT), (latin1_swedish_ci,COERCIBLE) for operation 'between'
571
select _latin1'B' in (_latin1'a',_latin1'b');
572
_latin1'B' in (_latin1'a',_latin1'b')
574
select _latin1'B' collate latin1_bin in (_latin1'a',_latin1'b');
575
_latin1'B' collate latin1_bin in (_latin1'a',_latin1'b')
577
select _latin1'B' in (_latin1'a' collate latin1_bin,_latin1'b');
578
_latin1'B' in (_latin1'a' collate latin1_bin,_latin1'b')
580
select _latin1'B' in (_latin1'a',_latin1'b' collate latin1_bin);
581
_latin1'B' in (_latin1'a',_latin1'b' collate latin1_bin)
583
select _latin2'B' in (_latin1'a',_latin1'b');
584
ERROR HY000: Illegal mix of collations (latin2_general_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE) for operation ' IN '
585
select _latin1'B' in (_latin2'a',_latin1'b');
586
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (latin2_general_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE) for operation ' IN '
587
select _latin1'B' in (_latin1'a',_latin2'b');
588
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE), (latin2_general_ci,COERCIBLE) for operation ' IN '
589
select _latin1'B' COLLATE latin1_general_ci in (_latin1'a' COLLATE latin1_bin,_latin1'b');
590
ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT), (latin1_bin,EXPLICIT), (latin1_swedish_ci,COERCIBLE) for operation ' IN '
591
select _latin1'B' COLLATE latin1_general_ci in (_latin1'a',_latin1'b' COLLATE latin1_bin);
592
ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT), (latin1_swedish_ci,COERCIBLE), (latin1_bin,EXPLICIT) for operation ' IN '
593
select collation(bin(130)), coercibility(bin(130));
594
collation(bin(130)) coercibility(bin(130))
596
select collation(oct(130)), coercibility(oct(130));
597
collation(oct(130)) coercibility(oct(130))
599
select collation(conv(130,16,10)), coercibility(conv(130,16,10));
600
collation(conv(130,16,10)) coercibility(conv(130,16,10))
602
select collation(hex(130)), coercibility(hex(130));
603
collation(hex(130)) coercibility(hex(130))
605
select collation(char(130)), coercibility(hex(130));
606
collation(char(130)) coercibility(hex(130))
608
select collation(format(130,10)), coercibility(format(130,10));
609
collation(format(130,10)) coercibility(format(130,10))
611
select collation(lcase(_latin2'a')), coercibility(lcase(_latin2'a'));
612
collation(lcase(_latin2'a')) coercibility(lcase(_latin2'a'))
614
select collation(ucase(_latin2'a')), coercibility(ucase(_latin2'a'));
615
collation(ucase(_latin2'a')) coercibility(ucase(_latin2'a'))
617
select collation(left(_latin2'a',1)), coercibility(left(_latin2'a',1));
618
collation(left(_latin2'a',1)) coercibility(left(_latin2'a',1))
620
select collation(right(_latin2'a',1)), coercibility(right(_latin2'a',1));
621
collation(right(_latin2'a',1)) coercibility(right(_latin2'a',1))
623
select collation(substring(_latin2'a',1,1)), coercibility(substring(_latin2'a',1,1));
624
collation(substring(_latin2'a',1,1)) coercibility(substring(_latin2'a',1,1))
626
select collation(concat(_latin2'a',_latin2'b')), coercibility(concat(_latin2'a',_latin2'b'));
627
collation(concat(_latin2'a',_latin2'b')) coercibility(concat(_latin2'a',_latin2'b'))
629
select collation(lpad(_latin2'a',4,_latin2'b')), coercibility(lpad(_latin2'a',4,_latin2'b'));
630
collation(lpad(_latin2'a',4,_latin2'b')) coercibility(lpad(_latin2'a',4,_latin2'b'))
632
select collation(rpad(_latin2'a',4,_latin2'b')), coercibility(rpad(_latin2'a',4,_latin2'b'));
633
collation(rpad(_latin2'a',4,_latin2'b')) coercibility(rpad(_latin2'a',4,_latin2'b'))
635
select collation(concat_ws(_latin2'a',_latin2'b')), coercibility(concat_ws(_latin2'a',_latin2'b'));
636
collation(concat_ws(_latin2'a',_latin2'b')) coercibility(concat_ws(_latin2'a',_latin2'b'))
638
select collation(make_set(255,_latin2'a',_latin2'b',_latin2'c')), coercibility(make_set(255,_latin2'a',_latin2'b',_latin2'c'));
639
collation(make_set(255,_latin2'a',_latin2'b',_latin2'c')) coercibility(make_set(255,_latin2'a',_latin2'b',_latin2'c'))
641
select collation(export_set(255,_latin2'y',_latin2'n',_latin2' ')), coercibility(export_set(255,_latin2'y',_latin2'n',_latin2' '));
642
collation(export_set(255,_latin2'y',_latin2'n',_latin2' ')) coercibility(export_set(255,_latin2'y',_latin2'n',_latin2' '))
644
select collation(trim(_latin2' a ')), coercibility(trim(_latin2' a '));
645
collation(trim(_latin2' a ')) coercibility(trim(_latin2' a '))
647
select collation(ltrim(_latin2' a ')), coercibility(ltrim(_latin2' a '));
648
collation(ltrim(_latin2' a ')) coercibility(ltrim(_latin2' a '))
650
select collation(rtrim(_latin2' a ')), coercibility(rtrim(_latin2' a '));
651
collation(rtrim(_latin2' a ')) coercibility(rtrim(_latin2' a '))
653
select collation(trim(LEADING _latin2' ' FROM _latin2'a')), coercibility(trim(LEADING _latin2'a' FROM _latin2'a'));
654
collation(trim(LEADING _latin2' ' FROM _latin2'a')) coercibility(trim(LEADING _latin2'a' FROM _latin2'a'))
656
select collation(trim(TRAILING _latin2' ' FROM _latin2'a')), coercibility(trim(TRAILING _latin2'a' FROM _latin2'a'));
657
collation(trim(TRAILING _latin2' ' FROM _latin2'a')) coercibility(trim(TRAILING _latin2'a' FROM _latin2'a'))
659
select collation(trim(BOTH _latin2' ' FROM _latin2'a')), coercibility(trim(BOTH _latin2'a' FROM _latin2'a'));
660
collation(trim(BOTH _latin2' ' FROM _latin2'a')) coercibility(trim(BOTH _latin2'a' FROM _latin2'a'))
662
select collation(repeat(_latin2'a',10)), coercibility(repeat(_latin2'a',10));
663
collation(repeat(_latin2'a',10)) coercibility(repeat(_latin2'a',10))
665
select collation(reverse(_latin2'ab')), coercibility(reverse(_latin2'ab'));
666
collation(reverse(_latin2'ab')) coercibility(reverse(_latin2'ab'))
668
select collation(quote(_latin2'ab')), coercibility(quote(_latin2'ab'));
669
collation(quote(_latin2'ab')) coercibility(quote(_latin2'ab'))
671
select collation(soundex(_latin2'ab')), coercibility(soundex(_latin2'ab'));
672
collation(soundex(_latin2'ab')) coercibility(soundex(_latin2'ab'))
674
select collation(substring(_latin2'ab',1)), coercibility(substring(_latin2'ab',1));
675
collation(substring(_latin2'ab',1)) coercibility(substring(_latin2'ab',1))
677
select collation(insert(_latin2'abcd',2,3,_latin2'ef')), coercibility(insert(_latin2'abcd',2,3,_latin2'ef'));
678
collation(insert(_latin2'abcd',2,3,_latin2'ef')) coercibility(insert(_latin2'abcd',2,3,_latin2'ef'))
680
select collation(replace(_latin2'abcd',_latin2'b',_latin2'B')), coercibility(replace(_latin2'abcd',_latin2'b',_latin2'B'));
681
collation(replace(_latin2'abcd',_latin2'b',_latin2'B')) coercibility(replace(_latin2'abcd',_latin2'b',_latin2'B'))
683
select collation(encode('abcd','ab')), coercibility(encode('abcd','ab'));
684
collation(encode('abcd','ab')) coercibility(encode('abcd','ab'))
698
substring(_latin2'a',1,1),
699
concat(_latin2'a',_latin2'b'),
700
lpad(_latin2'a',4,_latin2'b'),
701
rpad(_latin2'a',4,_latin2'b'),
702
concat_ws(_latin2'a',_latin2'b'),
703
make_set(255,_latin2'a',_latin2'b',_latin2'c'),
704
export_set(255,_latin2'y',_latin2'n',_latin2' '),
708
trim(LEADING _latin2' ' FROM _latin2' a '),
709
trim(TRAILING _latin2' ' FROM _latin2' a '),
710
trim(BOTH _latin2' ' FROM _latin2' a '),
711
repeat(_latin2'a',10),
712
reverse(_latin2'ab'),
714
soundex(_latin2'ab'),
715
substring(_latin2'ab',1),
716
insert(_latin2'abcd',2,3,_latin2'ef'),
717
replace(_latin2'abcd',_latin2'b',_latin2'B'),
721
Warning 1265 Data truncated for column 'format(130,10)' at row 1
722
show create table t1;
724
t1 CREATE TABLE `t1` (
725
`bin(130)` varchar(64) DEFAULT NULL,
726
`oct(130)` varchar(64) DEFAULT NULL,
727
`conv(130,16,10)` varchar(64) DEFAULT NULL,
728
`hex(130)` varchar(6) NOT NULL DEFAULT '',
729
`char(130)` varbinary(4) NOT NULL DEFAULT '',
730
`format(130,10)` varchar(4) NOT NULL DEFAULT '',
731
`left(_latin2'a',1)` varchar(1) CHARACTER SET latin2 NOT NULL DEFAULT '',
732
`right(_latin2'a',1)` varchar(1) CHARACTER SET latin2 NOT NULL DEFAULT '',
733
`lcase(_latin2'a')` varchar(1) CHARACTER SET latin2 NOT NULL DEFAULT '',
734
`ucase(_latin2'a')` varchar(1) CHARACTER SET latin2 NOT NULL DEFAULT '',
735
`substring(_latin2'a',1,1)` varchar(1) CHARACTER SET latin2 NOT NULL DEFAULT '',
736
`concat(_latin2'a',_latin2'b')` varchar(2) CHARACTER SET latin2 NOT NULL DEFAULT '',
737
`lpad(_latin2'a',4,_latin2'b')` varchar(4) CHARACTER SET latin2 NOT NULL DEFAULT '',
738
`rpad(_latin2'a',4,_latin2'b')` varchar(4) CHARACTER SET latin2 NOT NULL DEFAULT '',
739
`concat_ws(_latin2'a',_latin2'b')` varchar(1) CHARACTER SET latin2 NOT NULL DEFAULT '',
740
`make_set(255,_latin2'a',_latin2'b',_latin2'c')` varchar(5) CHARACTER SET latin2 NOT NULL DEFAULT '',
741
`export_set(255,_latin2'y',_latin2'n',_latin2' ')` varchar(127) CHARACTER SET latin2 NOT NULL DEFAULT '',
742
`trim(_latin2' a ')` varchar(3) CHARACTER SET latin2 NOT NULL DEFAULT '',
743
`ltrim(_latin2' a ')` varchar(3) CHARACTER SET latin2 NOT NULL DEFAULT '',
744
`rtrim(_latin2' a ')` varchar(3) CHARACTER SET latin2 NOT NULL DEFAULT '',
745
`trim(LEADING _latin2' ' FROM _latin2' a ')` varchar(3) CHARACTER SET latin2 NOT NULL DEFAULT '',
746
`trim(TRAILING _latin2' ' FROM _latin2' a ')` varchar(3) CHARACTER SET latin2 NOT NULL DEFAULT '',
747
`trim(BOTH _latin2' ' FROM _latin2' a ')` varchar(3) CHARACTER SET latin2 NOT NULL DEFAULT '',
748
`repeat(_latin2'a',10)` varchar(10) CHARACTER SET latin2 NOT NULL DEFAULT '',
749
`reverse(_latin2'ab')` varchar(2) CHARACTER SET latin2 NOT NULL DEFAULT '',
750
`quote(_latin2'ab')` varchar(6) CHARACTER SET latin2 NOT NULL DEFAULT '',
751
`soundex(_latin2'ab')` varchar(4) CHARACTER SET latin2 NOT NULL DEFAULT '',
752
`substring(_latin2'ab',1)` varchar(2) CHARACTER SET latin2 NOT NULL DEFAULT '',
753
`insert(_latin2'abcd',2,3,_latin2'ef')` varchar(6) CHARACTER SET latin2 NOT NULL DEFAULT '',
754
`replace(_latin2'abcd',_latin2'b',_latin2'B')` varchar(4) CHARACTER SET latin2 NOT NULL DEFAULT '',
755
`encode('abcd','ab')` varbinary(4) NOT NULL DEFAULT ''
756
) ENGINE=MyISAM DEFAULT CHARSET=latin1
758
create table t1 (a char character set latin2);
759
insert into t1 values (null);
760
select charset(a), collation(a), coercibility(a) from t1;
761
charset(a) collation(a) coercibility(a)
762
latin2 latin2_general_ci 2
764
select charset(null), collation(null), coercibility(null);
765
charset(null) collation(null) coercibility(null)
767
CREATE TABLE t1 (a int, b int);
768
CREATE TABLE t2 (a int, b int);
769
INSERT INTO t1 VALUES (1,1),(2,2);
770
INSERT INTO t2 VALUES (2,2),(3,3);
771
select t1.*,t2.* from t1 left join t2 on (t1.b=t2.b)
772
where collation(t2.a) = _utf8'binary' order by t1.a,t2.a;
776
select t1.*,t2.* from t1 left join t2 on (t1.b=t2.b)
777
where charset(t2.a) = _utf8'binary' order by t1.a,t2.a;
781
select t1.*,t2.* from t1 left join t2 on (t1.b=t2.b)
782
where coercibility(t2.a) = 2 order by t1.a,t2.a;
787
select SUBSTR('abcdefg',3,2);
788
SUBSTR('abcdefg',3,2)
790
select SUBSTRING('abcdefg',3,2);
791
SUBSTRING('abcdefg',3,2)
793
select SUBSTR('abcdefg',-3,2) FROM DUAL;
794
SUBSTR('abcdefg',-3,2)
796
select SUBSTR('abcdefg',-1,5) FROM DUAL;
797
SUBSTR('abcdefg',-1,5)
799
select SUBSTR('abcdefg',0,0) FROM DUAL;
800
SUBSTR('abcdefg',0,0)
802
select SUBSTR('abcdefg',-1,-1) FROM DUAL;
803
SUBSTR('abcdefg',-1,-1)
805
select SUBSTR('abcdefg',1,-1) FROM DUAL;
806
SUBSTR('abcdefg',1,-1)
808
create table t7 (s1 char);
810
where concat(s1 collate latin1_general_ci,s1 collate latin1_swedish_ci) = 'AA';
811
ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT) and (latin1_swedish_ci,EXPLICIT) for operation 'concat'
813
select substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2),substring_index("1abcd;2abcd;3abcd;4abcd", ';', -2);
814
substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2) substring_index("1abcd;2abcd;3abcd;4abcd", ';', -2)
815
1abcd;2abcd 3abcd;4abcd
816
explain extended select md5('hello');
817
id select_type table type possible_keys key key_len ref rows filtered Extra
818
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
820
Note 1003 select md5('hello') AS `md5('hello')`
821
explain extended select sha('abc');
822
id select_type table type possible_keys key key_len ref rows filtered Extra
823
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
825
Note 1003 select sha('abc') AS `sha('abc')`
826
explain extended select sha1('abc');
827
id select_type table type possible_keys key key_len ref rows filtered Extra
828
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
830
Note 1003 select sha('abc') AS `sha1('abc')`
831
explain extended select soundex('');
832
id select_type table type possible_keys key key_len ref rows filtered Extra
833
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
835
Note 1003 select soundex('') AS `soundex('')`
836
explain extended select 'mood' sounds like 'mud';
837
id select_type table type possible_keys key key_len ref rows filtered Extra
838
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
840
Note 1003 select (soundex('mood') = soundex('mud')) AS `'mood' sounds like 'mud'`
841
explain extended select aes_decrypt(aes_encrypt('abc','1'),'1');
842
id select_type table type possible_keys key key_len ref rows filtered Extra
843
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
845
Note 1003 select aes_decrypt(aes_encrypt('abc','1'),'1') AS `aes_decrypt(aes_encrypt('abc','1'),'1')`
846
explain extended select concat('*',space(5),'*');
847
id select_type table type possible_keys key key_len ref rows filtered Extra
848
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
850
Note 1003 select concat('*',repeat(' ',5),'*') AS `concat('*',space(5),'*')`
851
explain extended select reverse('abc');
852
id select_type table type possible_keys key key_len ref rows filtered Extra
853
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
855
Note 1003 select reverse('abc') AS `reverse('abc')`
856
explain extended select rpad('a',4,'1');
857
id select_type table type possible_keys key key_len ref rows filtered Extra
858
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
860
Note 1003 select rpad('a',4,'1') AS `rpad('a',4,'1')`
861
explain extended select lpad('a',4,'1');
862
id select_type table type possible_keys key key_len ref rows filtered Extra
863
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
865
Note 1003 select lpad('a',4,'1') AS `lpad('a',4,'1')`
866
explain extended select concat_ws(',','',NULL,'a');
867
id select_type table type possible_keys key key_len ref rows filtered Extra
868
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
870
Note 1003 select concat_ws(',','',NULL,'a') AS `concat_ws(',','',NULL,'a')`
871
explain extended select make_set(255,_latin2'a', _latin2'b', _latin2'c');
872
id select_type table type possible_keys key key_len ref rows filtered Extra
873
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
875
Note 1003 select make_set(255,_latin2'a',_latin2'b',_latin2'c') AS `make_set(255,_latin2'a', _latin2'b', _latin2'c')`
876
explain extended select elt(2,1);
877
id select_type table type possible_keys key key_len ref rows filtered Extra
878
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
880
Note 1003 select elt(2,1) AS `elt(2,1)`
881
explain extended select locate("a","b",2);
882
id select_type table type possible_keys key key_len ref rows filtered Extra
883
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
885
Note 1003 select locate('a','b',2) AS `locate("a","b",2)`
886
explain extended select format(130,10);
887
id select_type table type possible_keys key key_len ref rows filtered Extra
888
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
890
Note 1003 select format(130,10) AS `format(130,10)`
891
explain extended select char(0);
892
id select_type table type possible_keys key key_len ref rows filtered Extra
893
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
895
Note 1003 select char(0) AS `char(0)`
896
explain extended select conv(130,16,10);
897
id select_type table type possible_keys key key_len ref rows filtered Extra
898
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
900
Note 1003 select conv(130,16,10) AS `conv(130,16,10)`
901
explain extended select hex(130);
902
id select_type table type possible_keys key key_len ref rows filtered Extra
903
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
905
Note 1003 select hex(130) AS `hex(130)`
906
explain extended select binary 'HE';
907
id select_type table type possible_keys key key_len ref rows filtered Extra
908
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
910
Note 1003 select cast('HE' as char charset binary) AS `binary 'HE'`
911
explain extended select export_set(255,_latin2'y', _latin2'n', _latin2' ');
912
id select_type table type possible_keys key key_len ref rows filtered Extra
913
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
915
Note 1003 select export_set(255,_latin2'y',_latin2'n',_latin2' ') AS `export_set(255,_latin2'y', _latin2'n', _latin2' ')`
916
explain extended select FIELD('b' COLLATE latin1_bin,'A','B');
917
id select_type table type possible_keys key key_len ref rows filtered Extra
918
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
920
Note 1003 select field(('b' collate latin1_bin),'A','B') AS `FIELD('b' COLLATE latin1_bin,'A','B')`
921
explain extended select FIND_IN_SET(_latin1'B', _latin1'a,b,c,d');
922
id select_type table type possible_keys key key_len ref rows filtered Extra
923
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
925
Note 1003 select find_in_set(_latin1'B',_latin1'a,b,c,d') AS `FIND_IN_SET(_latin1'B', _latin1'a,b,c,d')`
926
explain extended select collation(conv(130,16,10));
927
id select_type table type possible_keys key key_len ref rows filtered Extra
928
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
930
Note 1003 select collation(conv(130,16,10)) AS `collation(conv(130,16,10))`
931
explain extended select coercibility(conv(130,16,10));
932
id select_type table type possible_keys key key_len ref rows filtered Extra
933
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
935
Note 1003 select coercibility(conv(130,16,10)) AS `coercibility(conv(130,16,10))`
936
explain extended select length('\n\t\r\b\0\_\%\\');
937
id select_type table type possible_keys key key_len ref rows filtered Extra
938
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
940
Note 1003 select length('\n \r\0\\_\\%\\') AS `length('\n\t\r\b\0\_\%\\')`
941
explain extended select bit_length('\n\t\r\b\0\_\%\\');
942
id select_type table type possible_keys key key_len ref rows filtered Extra
943
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
945
Note 1003 select bit_length('\n \r\0\\_\\%\\') AS `bit_length('\n\t\r\b\0\_\%\\')`
946
explain extended select bit_length('\n\t\r\b\0\_\%\\');
947
id select_type table type possible_keys key key_len ref rows filtered Extra
948
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
950
Note 1003 select bit_length('\n \r\0\\_\\%\\') AS `bit_length('\n\t\r\b\0\_\%\\')`
951
explain extended select concat('monty',' was here ','again');
952
id select_type table type possible_keys key key_len ref rows filtered Extra
953
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
955
Note 1003 select concat('monty',' was here ','again') AS `concat('monty',' was here ','again')`
956
explain extended select length('hello');
957
id select_type table type possible_keys key key_len ref rows filtered Extra
958
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
960
Note 1003 select length('hello') AS `length('hello')`
961
explain extended select char(ascii('h'));
962
id select_type table type possible_keys key key_len ref rows filtered Extra
963
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
965
Note 1003 select char(ascii('h')) AS `char(ascii('h'))`
966
explain extended select ord('h');
967
id select_type table type possible_keys key key_len ref rows filtered Extra
968
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
970
Note 1003 select ord('h') AS `ord('h')`
971
explain extended select quote(1/0);
972
id select_type table type possible_keys key key_len ref rows filtered Extra
973
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
975
Note 1003 select quote((1 / 0)) AS `quote(1/0)`
976
explain extended select crc32("123");
977
id select_type table type possible_keys key key_len ref rows filtered Extra
978
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
980
Note 1003 select crc32('123') AS `crc32("123")`
981
explain extended select replace('aaaa','a','b');
982
id select_type table type possible_keys key key_len ref rows filtered Extra
983
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
985
Note 1003 select replace('aaaa','a','b') AS `replace('aaaa','a','b')`
986
explain extended select insert('txs',2,1,'hi');
987
id select_type table type possible_keys key key_len ref rows filtered Extra
988
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
990
Note 1003 select insert('txs',2,1,'hi') AS `insert('txs',2,1,'hi')`
991
explain extended select left(_latin2'a',1);
992
id select_type table type possible_keys key key_len ref rows filtered Extra
993
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
995
Note 1003 select left(_latin2'a',1) AS `left(_latin2'a',1)`
996
explain extended select right(_latin2'a',1);
997
id select_type table type possible_keys key key_len ref rows filtered Extra
998
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
1000
Note 1003 select right(_latin2'a',1) AS `right(_latin2'a',1)`
1001
explain extended select lcase(_latin2'a');
1002
id select_type table type possible_keys key key_len ref rows filtered Extra
1003
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
1005
Note 1003 select lcase(_latin2'a') AS `lcase(_latin2'a')`
1006
explain extended select ucase(_latin2'a');
1007
id select_type table type possible_keys key key_len ref rows filtered Extra
1008
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
1010
Note 1003 select ucase(_latin2'a') AS `ucase(_latin2'a')`
1011
explain extended select SUBSTR('abcdefg',3,2);
1012
id select_type table type possible_keys key key_len ref rows filtered Extra
1013
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
1015
Note 1003 select substr('abcdefg',3,2) AS `SUBSTR('abcdefg',3,2)`
1016
explain extended select substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2);
1017
id select_type table type possible_keys key key_len ref rows filtered Extra
1018
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
1020
Note 1003 select substring_index('1abcd;2abcd;3abcd;4abcd',';',2) AS `substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2)`
1021
explain extended select trim(_latin2' a ');
1022
id select_type table type possible_keys key key_len ref rows filtered Extra
1023
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
1025
Note 1003 select trim(_latin2' a ') AS `trim(_latin2' a ')`
1026
explain extended select ltrim(_latin2' a ');
1027
id select_type table type possible_keys key key_len ref rows filtered Extra
1028
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
1030
Note 1003 select ltrim(_latin2' a ') AS `ltrim(_latin2' a ')`
1031
explain extended select rtrim(_latin2' a ');
1032
id select_type table type possible_keys key key_len ref rows filtered Extra
1033
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
1035
Note 1003 select rtrim(_latin2' a ') AS `rtrim(_latin2' a ')`
1036
explain extended select decode(encode(repeat("a",100000),"monty"),"monty");
1037
id select_type table type possible_keys key key_len ref rows filtered Extra
1038
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
1040
Note 1003 select decode(encode(repeat('a',100000),'monty'),'monty') AS `decode(encode(repeat("a",100000),"monty"),"monty")`
1041
SELECT lpad(12345, 5, "#");
1044
SELECT conv(71, 10, 36), conv('1Z', 36, 10);
1045
conv(71, 10, 36) conv('1Z', 36, 10)
1047
SELECT conv(71, 10, 37), conv('1Z', 37, 10), conv(0,1,10),conv(0,0,10), conv(0,-1,10);
1048
conv(71, 10, 37) conv('1Z', 37, 10) conv(0,1,10) conv(0,0,10) conv(0,-1,10)
1049
NULL NULL NULL NULL NULL
1050
create table t1 (id int(1), str varchar(10)) DEFAULT CHARSET=utf8;
1051
insert into t1 values (1,'aaaaaaaaaa'), (2,'bbbbbbbbbb');
1052
create table t2 (id int(1), str varchar(10)) DEFAULT CHARSET=utf8;
1053
insert into t2 values (1,'cccccccccc'), (2,'dddddddddd');
1054
select substring(concat(t1.str, t2.str), 1, 15) "name" from t1, t2
1055
where t2.id=t1.id order by name;
1060
create table t1 (c1 INT, c2 INT UNSIGNED);
1061
insert into t1 values ('21474836461','21474836461');
1063
Warning 1264 Out of range value for column 'c1' at row 1
1064
Warning 1264 Out of range value for column 'c2' at row 1
1065
insert into t1 values ('-21474836461','-21474836461');
1067
Warning 1264 Out of range value for column 'c1' at row 1
1068
Warning 1264 Out of range value for column 'c2' at row 1
1071
Warning 1264 Out of range value for column 'c1' at row 1
1072
Warning 1264 Out of range value for column 'c2' at row 1
1075
2147483647 4294967295
1078
select left(1234, 3) + 0;
1081
create table t1 (a int not null primary key, b varchar(40), c datetime);
1082
insert into t1 (a,b,c) values (1,'Tom','2004-12-10 12:13:14'),(2,'ball games','2004-12-10 12:13:14'), (3,'Basil','2004-12-10 12:13:14'), (4,'Dean','2004-12-10 12:13:14'),(5,'Ellis','2004-12-10 12:13:14'), (6,'Serg','2004-12-10 12:13:14'), (7,'Sergei','2004-12-10 12:13:14'),(8,'Georg','2004-12-10 12:13:14'),(9,'Salle','2004-12-10 12:13:14'),(10,'Sinisa','2004-12-10 12:13:14');
1083
select count(*) as total, left(c,10) as reg from t1 group by reg order by reg desc limit 0,12;
1087
select trim(null from 'kate') as "must_be_null";
1090
select trim('xyz' from null) as "must_be_null";
1093
select trim(leading NULL from 'kate') as "must_be_null";
1096
select trim(trailing NULL from 'xyz') as "must_be_null";
1100
id int(11) NOT NULL auto_increment,
1101
a bigint(20) unsigned default NULL,
1104
INSERT INTO t1 VALUES
1105
('0','16307858876001849059');
1106
SELECT CONV('e251273eb74a8ee3', 16, 10);
1107
CONV('e251273eb74a8ee3', 16, 10)
1108
16307858876001849059
1112
WHERE a = 16307858876001849059;
1113
id select_type table type possible_keys key key_len ref rows Extra
1114
1 SIMPLE t1 system NULL NULL NULL NULL 1
1118
WHERE a = CONV('e251273eb74a8ee3', 16, 10);
1119
id select_type table type possible_keys key key_len ref rows Extra
1120
1 SIMPLE t1 system NULL NULL NULL NULL 1
1122
SELECT CHAR(NULL,121,83,81,'76') as my_column;
1125
SELECT CHAR_LENGTH(CHAR(NULL,121,83,81,'76')) as my_column;
1128
CREATE TABLE t1 (id int PRIMARY KEY, str char(255) NOT NULL);
1129
CREATE TABLE t2 (id int NOT NULL UNIQUE);
1130
INSERT INTO t2 VALUES (1),(2);
1131
INSERT INTO t1 VALUES (1, aes_encrypt('foo', 'bar'));
1132
INSERT INTO t1 VALUES (2, 'not valid');
1133
SELECT t1.id, aes_decrypt(str, 'bar') FROM t1, t2 WHERE t1.id = t2.id;
1134
id aes_decrypt(str, 'bar')
1137
SELECT t1.id, aes_decrypt(str, 'bar') FROM t1, t2 WHERE t1.id = t2.id
1139
id aes_decrypt(str, 'bar')
1143
select field(0,NULL,1,0), field("",NULL,"bar",""), field(0.0,NULL,1.0,0.0);
1144
field(0,NULL,1,0) field("",NULL,"bar","") field(0.0,NULL,1.0,0.0)
1146
select field(NULL,1,2,NULL), field(NULL,1,2,0);
1147
field(NULL,1,2,NULL) field(NULL,1,2,0)
1149
CREATE TABLE t1 (str varchar(20) PRIMARY KEY);
1150
CREATE TABLE t2 (num int primary key);
1151
INSERT INTO t1 VALUES ('notnumber');
1152
INSERT INTO t2 VALUES (0), (1);
1153
SELECT * FROM t1, t2 WHERE num=str;
1156
SELECT * FROM t1, t2 WHERE num=substring(str from 1 for 6);
1161
id int(11) NOT NULL auto_increment,
1162
pc int(11) NOT NULL default '0',
1163
title varchar(20) default NULL,
1166
INSERT INTO t1 VALUES
1170
SELECT t1.id, CONCAT_WS('->', t3.title, t2.title, t1.title) as col1
1171
FROM t1 LEFT JOIN t1 AS t2 ON t1.pc=t2.id
1172
LEFT JOIN t1 AS t3 ON t2.pc=t3.id;
1177
SELECT t1.id, CONCAT_WS('->', t3.title, t2.title, t1.title) as col1
1178
FROM t1 LEFT JOIN t1 AS t2 ON t1.pc=t2.id
1179
LEFT JOIN t1 AS t3 ON t2.pc=t3.id
1180
WHERE CONCAT_WS('->', t3.title, t2.title, t1.title) LIKE '%Toys%';
1185
trackid int(10) unsigned NOT NULL auto_increment,
1186
trackname varchar(100) NOT NULL default '',
1187
PRIMARY KEY (trackid)
1190
artistid int(10) unsigned NOT NULL auto_increment,
1191
artistname varchar(100) NOT NULL default '',
1192
PRIMARY KEY (artistid)
1195
trackid int(10) unsigned NOT NULL,
1196
artistid int(10) unsigned NOT NULL,
1197
PRIMARY KEY (trackid,artistid)
1199
INSERT INTO t1 VALUES (1, 'April In Paris'), (2, 'Autumn In New York');
1200
INSERT INTO t2 VALUES (1, 'Vernon Duke');
1201
INSERT INTO t3 VALUES (1,1);
1202
SELECT CONCAT_WS(' ', trackname, artistname) trackname, artistname
1203
FROM t1 LEFT JOIN t3 ON t1.trackid=t3.trackid
1204
LEFT JOIN t2 ON t2.artistid=t3.artistid
1205
WHERE CONCAT_WS(' ', trackname, artistname) LIKE '%In%';
1206
trackname artistname
1207
April In Paris Vernon Duke Vernon Duke
1208
Autumn In New York NULL
1209
DROP TABLE t1,t2,t3;
1210
create table t1 (b varchar(5));
1211
insert t1 values ('ab'), ('abc'), ('abcd'), ('abcde');
1212
select *,substring(b,1),substring(b,-1),substring(b,-2),substring(b,-3),substring(b,-4),substring(b,-5) from t1;
1213
b substring(b,1) substring(b,-1) substring(b,-2) substring(b,-3) substring(b,-4) substring(b,-5)
1216
abcd abcd d cd bcd abcd
1217
abcde abcde e de cde bcde abcde
1218
select * from (select *,substring(b,1),substring(b,-1),substring(b,-2),substring(b,-3),substring(b,-4),substring(b,-5) from t1) t;
1219
b substring(b,1) substring(b,-1) substring(b,-2) substring(b,-3) substring(b,-4) substring(b,-5)
1222
abcd abcd d cd bcd abcd
1223
abcde abcde e de cde bcde abcde
1225
select hex(29223372036854775809), hex(-29223372036854775809);
1226
hex(29223372036854775809) hex(-29223372036854775809)
1227
FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF
1228
create table t1 (i int);
1229
insert into t1 values (1000000000),(1);
1230
select lpad(i, 7, ' ') as t from t1;
1231
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
1232
def t 253 7 7 Y 128 31 63
1236
select rpad(i, 7, ' ') as t from t1;
1237
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
1238
def t 253 7 7 Y 128 31 63
1243
select load_file("lkjlkj");
1246
select ifnull(load_file("lkjlkj"),"it's null");
1247
ifnull(load_file("lkjlkj"),"it's null")
1249
create table t1 (f1 varchar(4), f2 varchar(64), unique key k1 (f1,f2));
1250
insert into t1 values ( 'test',md5('test')), ('test', sha('test'));
1251
select * from t1 where f1='test' and (f2= md5("test") or f2= md5("TEST"));
1253
test 098f6bcd4621d373cade4e832627b4f6
1254
select * from t1 where f1='test' and (f2= md5("TEST") or f2= md5("test"));
1256
test 098f6bcd4621d373cade4e832627b4f6
1257
select * from t1 where f1='test' and (f2= sha("test") or f2= sha("TEST"));
1259
test a94a8fe5ccb19ba61c4c0873d391e987982fbbd3
1260
select * from t1 where f1='test' and (f2= sha("TEST") or f2= sha("test"));
1262
test a94a8fe5ccb19ba61c4c0873d391e987982fbbd3
1264
CREATE TABLE t1 (a varchar(10));
1265
INSERT INTO t1 VALUES ('abc'), ('xyz');
1266
SELECT a, CONCAT(a,' ',a) AS c FROM t1
1267
HAVING LEFT(c,LENGTH(c)-INSTR(REVERSE(c)," ")) = a;
1271
SELECT a, CONCAT(a,' ',a) AS c FROM t1
1272
HAVING LEFT(CONCAT(a,' ',a),
1273
LENGTH(CONCAT(a,' ',a))-
1274
INSTR(REVERSE(CONCAT(a,' ',a))," ")) = a;
1279
CREATE TABLE t1 (s varchar(10));
1280
INSERT INTO t1 VALUES ('yadda'), ('yaddy');
1281
EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(s) > 'ab';
1282
id select_type table type possible_keys key key_len ref rows filtered Extra
1283
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
1285
Note 1003 select `test`.`t1`.`s` AS `s` from `test`.`t1` where (trim(`test`.`t1`.`s`) > 'ab')
1286
EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM('y' FROM s) > 'ab';
1287
id select_type table type possible_keys key key_len ref rows filtered Extra
1288
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
1290
Note 1003 select `test`.`t1`.`s` AS `s` from `test`.`t1` where (trim(both 'y' from `test`.`t1`.`s`) > 'ab')
1291
EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(LEADING 'y' FROM s) > 'ab';
1292
id select_type table type possible_keys key key_len ref rows filtered Extra
1293
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
1295
Note 1003 select `test`.`t1`.`s` AS `s` from `test`.`t1` where (trim(leading 'y' from `test`.`t1`.`s`) > 'ab')
1296
EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(TRAILING 'y' FROM s) > 'ab';
1297
id select_type table type possible_keys key key_len ref rows filtered Extra
1298
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
1300
Note 1003 select `test`.`t1`.`s` AS `s` from `test`.`t1` where (trim(trailing 'y' from `test`.`t1`.`s`) > 'ab')
1301
EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(BOTH 'y' FROM s) > 'ab';
1302
id select_type table type possible_keys key key_len ref rows filtered Extra
1303
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
1305
Note 1003 select `test`.`t1`.`s` AS `s` from `test`.`t1` where (trim(both 'y' from `test`.`t1`.`s`) > 'ab')
1307
create table t1(f1 varchar(4));
1308
explain extended select encode(f1,'zxcv') as 'enc' from t1;
1309
id select_type table type possible_keys key key_len ref rows filtered Extra
1310
1 SIMPLE t1 system NULL NULL NULL NULL 0 0.00 const row not found
1312
Note 1003 select encode('','zxcv') AS `enc` from `test`.`t1`
1313
explain extended select decode(f1,'zxcv') as 'enc' from t1;
1314
id select_type table type possible_keys key key_len ref rows filtered Extra
1315
1 SIMPLE t1 system NULL NULL NULL NULL 0 0.00 const row not found
1317
Note 1003 select decode('','zxcv') AS `enc` from `test`.`t1`
1319
create table t1 (a bigint not null)engine=myisam;
1320
insert into t1 set a = 1024*1024*1024*4;
1321
delete from t1 order by (inet_ntoa(a)) desc limit 10;
1323
create table t1 (a char(36) not null)engine=myisam;
1324
insert ignore into t1 set a = ' ';
1325
insert ignore into t1 set a = ' ';
1326
select * from t1 order by (oct(a));
1332
create table t1 (d decimal default null);
1333
insert into t1 values (null);
1334
select format(d, 2) from t1;
1338
create table t1 (c varchar(40));
1339
insert into t1 values ('y,abc'),('y,abc');
1340
select c, substring_index(lcase(c), @q:=',', -1) as res from t1;
1345
select cast(rtrim(' 20.06 ') as decimal(19,2));
1346
cast(rtrim(' 20.06 ') as decimal(19,2))
1348
select cast(ltrim(' 20.06 ') as decimal(19,2));
1349
cast(ltrim(' 20.06 ') as decimal(19,2))
1351
select cast(rtrim(ltrim(' 20.06 ')) as decimal(19,2));
1352
cast(rtrim(ltrim(' 20.06 ')) as decimal(19,2))
1354
select conv("18383815659218730760",10,10) + 0;
1355
conv("18383815659218730760",10,10) + 0
1356
1.838381565921873e19
1357
select "18383815659218730760" + 0;
1358
"18383815659218730760" + 0
1359
1.838381565921873e19
1360
CREATE TABLE t1 (code varchar(10));
1361
INSERT INTO t1 VALUES ('a12'), ('A12'), ('a13');
1362
SELECT ASCII(code), code FROM t1 WHERE code='A12';
1366
SELECT ASCII(code), code FROM t1 WHERE code='A12' AND ASCII(code)=65;
1369
INSERT INTO t1 VALUES ('a12 '), ('A12 ');
1370
SELECT LENGTH(code), code FROM t1 WHERE code='A12';
1376
SELECT LENGTH(code), code FROM t1 WHERE code='A12' AND LENGTH(code)=5;
1379
ALTER TABLE t1 ADD INDEX (code);
1380
CREATE TABLE t2 (id varchar(10) PRIMARY KEY);
1381
INSERT INTO t2 VALUES ('a11'), ('a12'), ('a13'), ('a14');
1382
SELECT * FROM t1 INNER JOIN t2 ON t1.code=t2.id
1383
WHERE t2.id='a12' AND (LENGTH(code)=5 OR code < 'a00');
1387
SELECT * FROM t1 INNER JOIN t2 ON code=id
1388
WHERE id='a12' AND (LENGTH(code)=5 OR code < 'a00');
1389
id select_type table type possible_keys key key_len ref rows filtered Extra
1390
1 SIMPLE t2 const PRIMARY PRIMARY 12 const 1 100.00 Using index
1391
1 SIMPLE t1 ref code code 13 const 3 100.00 Using where; Using index
1393
Note 1003 select `test`.`t1`.`code` AS `code`,'a12' AS `id` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`code` = 'a12') and (length(`test`.`t1`.`code`) = 5))
1395
select encode(NULL, NULL);
1398
select encode("data", NULL);
1399
encode("data", NULL)
1401
select encode(NULL, "password");
1402
encode(NULL, "password")
1404
select decode(NULL, NULL);
1407
select decode("data", NULL);
1408
decode("data", NULL)
1410
select decode(NULL, "password");
1411
decode(NULL, "password")
1413
select format(NULL, NULL);
1416
select format(pi(), NULL);
1419
select format(NULL, 2);
1422
select benchmark(NULL, NULL);
1423
benchmark(NULL, NULL)
1425
select benchmark(0, NULL);
1428
select benchmark(100, NULL);
1429
benchmark(100, NULL)
1431
select benchmark(NULL, 1+1);
1432
benchmark(NULL, 1+1)
1434
select benchmark(-1, 1);
1438
Error 1411 Incorrect count value: '-1' for function benchmark
1439
set @password="password";
1440
set @my_data="clear text to encode";
1441
select md5(encode(@my_data, "password"));
1442
md5(encode(@my_data, "password"))
1443
44320fd2b4a0ec92faa2da2122def917
1444
select md5(encode(@my_data, _utf8 "password"));
1445
md5(encode(@my_data, _utf8 "password"))
1446
44320fd2b4a0ec92faa2da2122def917
1447
select md5(encode(@my_data, binary "password"));
1448
md5(encode(@my_data, binary "password"))
1449
44320fd2b4a0ec92faa2da2122def917
1450
select md5(encode(@my_data, _latin1 "password"));
1451
md5(encode(@my_data, _latin1 "password"))
1452
44320fd2b4a0ec92faa2da2122def917
1453
select md5(encode(@my_data, _koi8r "password"));
1454
md5(encode(@my_data, _koi8r "password"))
1455
44320fd2b4a0ec92faa2da2122def917
1456
select md5(encode(@my_data, (select "password" from dual)));
1457
md5(encode(@my_data, (select "password" from dual)))
1458
44320fd2b4a0ec92faa2da2122def917
1459
select md5(encode(@my_data, concat("pass", "word")));
1460
md5(encode(@my_data, concat("pass", "word")))
1461
44320fd2b4a0ec92faa2da2122def917
1462
select md5(encode(@my_data, @password));
1463
md5(encode(@my_data, @password))
1464
44320fd2b4a0ec92faa2da2122def917
1465
set @my_data="binary encoded data";
1466
select md5(decode(@my_data, "password"));
1467
md5(decode(@my_data, "password"))
1468
5bea8c394368dbc03b76684483b7756b
1469
select md5(decode(@my_data, _utf8 "password"));
1470
md5(decode(@my_data, _utf8 "password"))
1471
5bea8c394368dbc03b76684483b7756b
1472
select md5(decode(@my_data, binary "password"));
1473
md5(decode(@my_data, binary "password"))
1474
5bea8c394368dbc03b76684483b7756b
1475
select md5(decode(@my_data, _latin1 "password"));
1476
md5(decode(@my_data, _latin1 "password"))
1477
5bea8c394368dbc03b76684483b7756b
1478
select md5(decode(@my_data, _koi8r "password"));
1479
md5(decode(@my_data, _koi8r "password"))
1480
5bea8c394368dbc03b76684483b7756b
1481
select md5(decode(@my_data, (select "password" from dual)));
1482
md5(decode(@my_data, (select "password" from dual)))
1483
5bea8c394368dbc03b76684483b7756b
1484
select md5(decode(@my_data, concat("pass", "word")));
1485
md5(decode(@my_data, concat("pass", "word")))
1486
5bea8c394368dbc03b76684483b7756b
1487
select md5(decode(@my_data, @password));
1488
md5(decode(@my_data, @password))
1489
5bea8c394368dbc03b76684483b7756b
1491
select format(pi(), (1+1));
1494
select format(pi(), (select 3 from dual));
1495
format(pi(), (select 3 from dual))
1497
select format(pi(), @dec);
1500
set @bench_count=10;
1501
select benchmark(10, pi());
1504
select benchmark(5+5, pi());
1505
benchmark(5+5, pi())
1507
select benchmark((select 10 from dual), pi());
1508
benchmark((select 10 from dual), pi())
1510
select benchmark(@bench_count, pi());
1511
benchmark(@bench_count, pi())
1513
select locate('he','hello',-2);
1514
locate('he','hello',-2)
1516
select locate('lo','hello',-4294967295);
1517
locate('lo','hello',-4294967295)
1519
select locate('lo','hello',4294967295);
1520
locate('lo','hello',4294967295)
1522
select locate('lo','hello',-4294967296);
1523
locate('lo','hello',-4294967296)
1525
select locate('lo','hello',4294967296);
1526
locate('lo','hello',4294967296)
1528
select locate('lo','hello',-4294967297);
1529
locate('lo','hello',-4294967297)
1531
select locate('lo','hello',4294967297);
1532
locate('lo','hello',4294967297)
1534
select locate('lo','hello',-18446744073709551615);
1535
locate('lo','hello',-18446744073709551615)
1538
Error 1292 Truncated incorrect DECIMAL value: ''
1539
select locate('lo','hello',18446744073709551615);
1540
locate('lo','hello',18446744073709551615)
1542
select locate('lo','hello',-18446744073709551616);
1543
locate('lo','hello',-18446744073709551616)
1546
Error 1292 Truncated incorrect DECIMAL value: ''
1547
select locate('lo','hello',18446744073709551616);
1548
locate('lo','hello',18446744073709551616)
1551
Error 1292 Truncated incorrect DECIMAL value: ''
1552
select locate('lo','hello',-18446744073709551617);
1553
locate('lo','hello',-18446744073709551617)
1556
Error 1292 Truncated incorrect DECIMAL value: ''
1557
select locate('lo','hello',18446744073709551617);
1558
locate('lo','hello',18446744073709551617)
1561
Error 1292 Truncated incorrect DECIMAL value: ''
1562
select left('hello', 10);
1565
select left('hello', 0);
1568
select left('hello', -1);
1571
select left('hello', -4294967295);
1572
left('hello', -4294967295)
1574
select left('hello', 4294967295);
1575
left('hello', 4294967295)
1577
select left('hello', -4294967296);
1578
left('hello', -4294967296)
1580
select left('hello', 4294967296);
1581
left('hello', 4294967296)
1583
select left('hello', -4294967297);
1584
left('hello', -4294967297)
1586
select left('hello', 4294967297);
1587
left('hello', 4294967297)
1589
select left('hello', -18446744073709551615);
1590
left('hello', -18446744073709551615)
1593
Error 1292 Truncated incorrect DECIMAL value: ''
1594
Error 1292 Truncated incorrect DECIMAL value: ''
1595
select left('hello', 18446744073709551615);
1596
left('hello', 18446744073709551615)
1598
select left('hello', -18446744073709551616);
1599
left('hello', -18446744073709551616)
1602
Error 1292 Truncated incorrect DECIMAL value: ''
1603
Error 1292 Truncated incorrect DECIMAL value: ''
1604
select left('hello', 18446744073709551616);
1605
left('hello', 18446744073709551616)
1608
Error 1292 Truncated incorrect DECIMAL value: ''
1609
Error 1292 Truncated incorrect DECIMAL value: ''
1610
select left('hello', -18446744073709551617);
1611
left('hello', -18446744073709551617)
1614
Error 1292 Truncated incorrect DECIMAL value: ''
1615
Error 1292 Truncated incorrect DECIMAL value: ''
1616
select left('hello', 18446744073709551617);
1617
left('hello', 18446744073709551617)
1620
Error 1292 Truncated incorrect DECIMAL value: ''
1621
Error 1292 Truncated incorrect DECIMAL value: ''
1622
select right('hello', 10);
1625
select right('hello', 0);
1628
select right('hello', -1);
1631
select right('hello', -4294967295);
1632
right('hello', -4294967295)
1634
select right('hello', 4294967295);
1635
right('hello', 4294967295)
1637
select right('hello', -4294967296);
1638
right('hello', -4294967296)
1640
select right('hello', 4294967296);
1641
right('hello', 4294967296)
1643
select right('hello', -4294967297);
1644
right('hello', -4294967297)
1646
select right('hello', 4294967297);
1647
right('hello', 4294967297)
1649
select right('hello', -18446744073709551615);
1650
right('hello', -18446744073709551615)
1653
Error 1292 Truncated incorrect DECIMAL value: ''
1654
Error 1292 Truncated incorrect DECIMAL value: ''
1655
select right('hello', 18446744073709551615);
1656
right('hello', 18446744073709551615)
1658
select right('hello', -18446744073709551616);
1659
right('hello', -18446744073709551616)
1662
Error 1292 Truncated incorrect DECIMAL value: ''
1663
Error 1292 Truncated incorrect DECIMAL value: ''
1664
select right('hello', 18446744073709551616);
1665
right('hello', 18446744073709551616)
1668
Error 1292 Truncated incorrect DECIMAL value: ''
1669
Error 1292 Truncated incorrect DECIMAL value: ''
1670
select right('hello', -18446744073709551617);
1671
right('hello', -18446744073709551617)
1674
Error 1292 Truncated incorrect DECIMAL value: ''
1675
Error 1292 Truncated incorrect DECIMAL value: ''
1676
select right('hello', 18446744073709551617);
1677
right('hello', 18446744073709551617)
1680
Error 1292 Truncated incorrect DECIMAL value: ''
1681
Error 1292 Truncated incorrect DECIMAL value: ''
1682
select substring('hello', 2, -1);
1683
substring('hello', 2, -1)
1685
select substring('hello', -1, 1);
1686
substring('hello', -1, 1)
1688
select substring('hello', -2, 1);
1689
substring('hello', -2, 1)
1691
select substring('hello', -4294967295, 1);
1692
substring('hello', -4294967295, 1)
1694
select substring('hello', 4294967295, 1);
1695
substring('hello', 4294967295, 1)
1697
select substring('hello', -4294967296, 1);
1698
substring('hello', -4294967296, 1)
1700
select substring('hello', 4294967296, 1);
1701
substring('hello', 4294967296, 1)
1703
select substring('hello', -4294967297, 1);
1704
substring('hello', -4294967297, 1)
1706
select substring('hello', 4294967297, 1);
1707
substring('hello', 4294967297, 1)
1709
select substring('hello', -18446744073709551615, 1);
1710
substring('hello', -18446744073709551615, 1)
1713
Error 1292 Truncated incorrect DECIMAL value: ''
1714
Error 1292 Truncated incorrect DECIMAL value: ''
1715
select substring('hello', 18446744073709551615, 1);
1716
substring('hello', 18446744073709551615, 1)
1718
select substring('hello', -18446744073709551616, 1);
1719
substring('hello', -18446744073709551616, 1)
1722
Error 1292 Truncated incorrect DECIMAL value: ''
1723
Error 1292 Truncated incorrect DECIMAL value: ''
1724
select substring('hello', 18446744073709551616, 1);
1725
substring('hello', 18446744073709551616, 1)
1728
Error 1292 Truncated incorrect DECIMAL value: ''
1729
Error 1292 Truncated incorrect DECIMAL value: ''
1730
select substring('hello', -18446744073709551617, 1);
1731
substring('hello', -18446744073709551617, 1)
1734
Error 1292 Truncated incorrect DECIMAL value: ''
1735
Error 1292 Truncated incorrect DECIMAL value: ''
1736
select substring('hello', 18446744073709551617, 1);
1737
substring('hello', 18446744073709551617, 1)
1740
Error 1292 Truncated incorrect DECIMAL value: ''
1741
Error 1292 Truncated incorrect DECIMAL value: ''
1742
select substring('hello', 1, -1);
1743
substring('hello', 1, -1)
1745
select substring('hello', 1, -4294967295);
1746
substring('hello', 1, -4294967295)
1748
select substring('hello', 1, 4294967295);
1749
substring('hello', 1, 4294967295)
1751
select substring('hello', 1, -4294967296);
1752
substring('hello', 1, -4294967296)
1754
select substring('hello', 1, 4294967296);
1755
substring('hello', 1, 4294967296)
1757
select substring('hello', 1, -4294967297);
1758
substring('hello', 1, -4294967297)
1760
select substring('hello', 1, 4294967297);
1761
substring('hello', 1, 4294967297)
1763
select substring('hello', 1, -18446744073709551615);
1764
substring('hello', 1, -18446744073709551615)
1767
Error 1292 Truncated incorrect DECIMAL value: ''
1768
Error 1292 Truncated incorrect DECIMAL value: ''
1769
select substring('hello', 1, 18446744073709551615);
1770
substring('hello', 1, 18446744073709551615)
1772
select substring('hello', 1, -18446744073709551616);
1773
substring('hello', 1, -18446744073709551616)
1776
Error 1292 Truncated incorrect DECIMAL value: ''
1777
Error 1292 Truncated incorrect DECIMAL value: ''
1778
select substring('hello', 1, 18446744073709551616);
1779
substring('hello', 1, 18446744073709551616)
1782
Error 1292 Truncated incorrect DECIMAL value: ''
1783
Error 1292 Truncated incorrect DECIMAL value: ''
1784
select substring('hello', 1, -18446744073709551617);
1785
substring('hello', 1, -18446744073709551617)
1788
Error 1292 Truncated incorrect DECIMAL value: ''
1789
Error 1292 Truncated incorrect DECIMAL value: ''
1790
select substring('hello', 1, 18446744073709551617);
1791
substring('hello', 1, 18446744073709551617)
1794
Error 1292 Truncated incorrect DECIMAL value: ''
1795
Error 1292 Truncated incorrect DECIMAL value: ''
1796
select substring('hello', -1, -1);
1797
substring('hello', -1, -1)
1799
select substring('hello', -4294967295, -4294967295);
1800
substring('hello', -4294967295, -4294967295)
1802
select substring('hello', 4294967295, 4294967295);
1803
substring('hello', 4294967295, 4294967295)
1805
select substring('hello', -4294967296, -4294967296);
1806
substring('hello', -4294967296, -4294967296)
1808
select substring('hello', 4294967296, 4294967296);
1809
substring('hello', 4294967296, 4294967296)
1811
select substring('hello', -4294967297, -4294967297);
1812
substring('hello', -4294967297, -4294967297)
1814
select substring('hello', 4294967297, 4294967297);
1815
substring('hello', 4294967297, 4294967297)
1817
select substring('hello', -18446744073709551615, -18446744073709551615);
1818
substring('hello', -18446744073709551615, -18446744073709551615)
1821
Error 1292 Truncated incorrect DECIMAL value: ''
1822
Error 1292 Truncated incorrect DECIMAL value: ''
1823
Error 1292 Truncated incorrect DECIMAL value: ''
1824
Error 1292 Truncated incorrect DECIMAL value: ''
1825
select substring('hello', 18446744073709551615, 18446744073709551615);
1826
substring('hello', 18446744073709551615, 18446744073709551615)
1828
select substring('hello', -18446744073709551616, -18446744073709551616);
1829
substring('hello', -18446744073709551616, -18446744073709551616)
1832
Error 1292 Truncated incorrect DECIMAL value: ''
1833
Error 1292 Truncated incorrect DECIMAL value: ''
1834
Error 1292 Truncated incorrect DECIMAL value: ''
1835
Error 1292 Truncated incorrect DECIMAL value: ''
1836
select substring('hello', 18446744073709551616, 18446744073709551616);
1837
substring('hello', 18446744073709551616, 18446744073709551616)
1840
Error 1292 Truncated incorrect DECIMAL value: ''
1841
Error 1292 Truncated incorrect DECIMAL value: ''
1842
Error 1292 Truncated incorrect DECIMAL value: ''
1843
Error 1292 Truncated incorrect DECIMAL value: ''
1844
select substring('hello', -18446744073709551617, -18446744073709551617);
1845
substring('hello', -18446744073709551617, -18446744073709551617)
1848
Error 1292 Truncated incorrect DECIMAL value: ''
1849
Error 1292 Truncated incorrect DECIMAL value: ''
1850
Error 1292 Truncated incorrect DECIMAL value: ''
1851
Error 1292 Truncated incorrect DECIMAL value: ''
1852
select substring('hello', 18446744073709551617, 18446744073709551617);
1853
substring('hello', 18446744073709551617, 18446744073709551617)
1856
Error 1292 Truncated incorrect DECIMAL value: ''
1857
Error 1292 Truncated incorrect DECIMAL value: ''
1858
Error 1292 Truncated incorrect DECIMAL value: ''
1859
Error 1292 Truncated incorrect DECIMAL value: ''
1860
select insert('hello', -1, 1, 'hi');
1861
insert('hello', -1, 1, 'hi')
1863
select insert('hello', -4294967295, 1, 'hi');
1864
insert('hello', -4294967295, 1, 'hi')
1866
select insert('hello', 4294967295, 1, 'hi');
1867
insert('hello', 4294967295, 1, 'hi')
1869
select insert('hello', -4294967296, 1, 'hi');
1870
insert('hello', -4294967296, 1, 'hi')
1872
select insert('hello', 4294967296, 1, 'hi');
1873
insert('hello', 4294967296, 1, 'hi')
1875
select insert('hello', -4294967297, 1, 'hi');
1876
insert('hello', -4294967297, 1, 'hi')
1878
select insert('hello', 4294967297, 1, 'hi');
1879
insert('hello', 4294967297, 1, 'hi')
1881
select insert('hello', -18446744073709551615, 1, 'hi');
1882
insert('hello', -18446744073709551615, 1, 'hi')
1885
Error 1292 Truncated incorrect DECIMAL value: ''
1886
select insert('hello', 18446744073709551615, 1, 'hi');
1887
insert('hello', 18446744073709551615, 1, 'hi')
1889
select insert('hello', -18446744073709551616, 1, 'hi');
1890
insert('hello', -18446744073709551616, 1, 'hi')
1893
Error 1292 Truncated incorrect DECIMAL value: ''
1894
select insert('hello', 18446744073709551616, 1, 'hi');
1895
insert('hello', 18446744073709551616, 1, 'hi')
1898
Error 1292 Truncated incorrect DECIMAL value: ''
1899
select insert('hello', -18446744073709551617, 1, 'hi');
1900
insert('hello', -18446744073709551617, 1, 'hi')
1903
Error 1292 Truncated incorrect DECIMAL value: ''
1904
select insert('hello', 18446744073709551617, 1, 'hi');
1905
insert('hello', 18446744073709551617, 1, 'hi')
1908
Error 1292 Truncated incorrect DECIMAL value: ''
1909
select insert('hello', 1, -1, 'hi');
1910
insert('hello', 1, -1, 'hi')
1912
select insert('hello', 1, -4294967295, 'hi');
1913
insert('hello', 1, -4294967295, 'hi')
1915
select insert('hello', 1, 4294967295, 'hi');
1916
insert('hello', 1, 4294967295, 'hi')
1918
select insert('hello', 1, -4294967296, 'hi');
1919
insert('hello', 1, -4294967296, 'hi')
1921
select insert('hello', 1, 4294967296, 'hi');
1922
insert('hello', 1, 4294967296, 'hi')
1924
select insert('hello', 1, -4294967297, 'hi');
1925
insert('hello', 1, -4294967297, 'hi')
1927
select insert('hello', 1, 4294967297, 'hi');
1928
insert('hello', 1, 4294967297, 'hi')
1930
select insert('hello', 1, -18446744073709551615, 'hi');
1931
insert('hello', 1, -18446744073709551615, 'hi')
1934
Error 1292 Truncated incorrect DECIMAL value: ''
1935
select insert('hello', 1, 18446744073709551615, 'hi');
1936
insert('hello', 1, 18446744073709551615, 'hi')
1938
select insert('hello', 1, -18446744073709551616, 'hi');
1939
insert('hello', 1, -18446744073709551616, 'hi')
1942
Error 1292 Truncated incorrect DECIMAL value: ''
1943
select insert('hello', 1, 18446744073709551616, 'hi');
1944
insert('hello', 1, 18446744073709551616, 'hi')
1947
Error 1292 Truncated incorrect DECIMAL value: ''
1948
select insert('hello', 1, -18446744073709551617, 'hi');
1949
insert('hello', 1, -18446744073709551617, 'hi')
1952
Error 1292 Truncated incorrect DECIMAL value: ''
1953
select insert('hello', 1, 18446744073709551617, 'hi');
1954
insert('hello', 1, 18446744073709551617, 'hi')
1957
Error 1292 Truncated incorrect DECIMAL value: ''
1958
select insert('hello', -1, -1, 'hi');
1959
insert('hello', -1, -1, 'hi')
1961
select insert('hello', -4294967295, -4294967295, 'hi');
1962
insert('hello', -4294967295, -4294967295, 'hi')
1964
select insert('hello', 4294967295, 4294967295, 'hi');
1965
insert('hello', 4294967295, 4294967295, 'hi')
1967
select insert('hello', -4294967296, -4294967296, 'hi');
1968
insert('hello', -4294967296, -4294967296, 'hi')
1970
select insert('hello', 4294967296, 4294967296, 'hi');
1971
insert('hello', 4294967296, 4294967296, 'hi')
1973
select insert('hello', -4294967297, -4294967297, 'hi');
1974
insert('hello', -4294967297, -4294967297, 'hi')
1976
select insert('hello', 4294967297, 4294967297, 'hi');
1977
insert('hello', 4294967297, 4294967297, 'hi')
1979
select insert('hello', -18446744073709551615, -18446744073709551615, 'hi');
1980
insert('hello', -18446744073709551615, -18446744073709551615, 'hi')
1983
Error 1292 Truncated incorrect DECIMAL value: ''
1984
Error 1292 Truncated incorrect DECIMAL value: ''
1985
select insert('hello', 18446744073709551615, 18446744073709551615, 'hi');
1986
insert('hello', 18446744073709551615, 18446744073709551615, 'hi')
1988
select insert('hello', -18446744073709551616, -18446744073709551616, 'hi');
1989
insert('hello', -18446744073709551616, -18446744073709551616, 'hi')
1992
Error 1292 Truncated incorrect DECIMAL value: ''
1993
Error 1292 Truncated incorrect DECIMAL value: ''
1994
select insert('hello', 18446744073709551616, 18446744073709551616, 'hi');
1995
insert('hello', 18446744073709551616, 18446744073709551616, 'hi')
1998
Error 1292 Truncated incorrect DECIMAL value: ''
1999
Error 1292 Truncated incorrect DECIMAL value: ''
2000
select insert('hello', -18446744073709551617, -18446744073709551617, 'hi');
2001
insert('hello', -18446744073709551617, -18446744073709551617, 'hi')
2004
Error 1292 Truncated incorrect DECIMAL value: ''
2005
Error 1292 Truncated incorrect DECIMAL value: ''
2006
select insert('hello', 18446744073709551617, 18446744073709551617, 'hi');
2007
insert('hello', 18446744073709551617, 18446744073709551617, 'hi')
2010
Error 1292 Truncated incorrect DECIMAL value: ''
2011
Error 1292 Truncated incorrect DECIMAL value: ''
2012
select repeat('hello', -1);
2015
select repeat('hello', -4294967295);
2016
repeat('hello', -4294967295)
2018
select repeat('hello', 4294967295);
2019
repeat('hello', 4294967295)
2022
Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
2023
select repeat('hello', -4294967296);
2024
repeat('hello', -4294967296)
2026
select repeat('hello', 4294967296);
2027
repeat('hello', 4294967296)
2030
Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
2031
select repeat('hello', -4294967297);
2032
repeat('hello', -4294967297)
2034
select repeat('hello', 4294967297);
2035
repeat('hello', 4294967297)
2038
Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
2039
select repeat('hello', -18446744073709551615);
2040
repeat('hello', -18446744073709551615)
2043
Error 1292 Truncated incorrect DECIMAL value: ''
2044
Error 1292 Truncated incorrect DECIMAL value: ''
2045
select repeat('hello', 18446744073709551615);
2046
repeat('hello', 18446744073709551615)
2049
Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
2050
select repeat('hello', -18446744073709551616);
2051
repeat('hello', -18446744073709551616)
2054
Error 1292 Truncated incorrect DECIMAL value: ''
2055
Error 1292 Truncated incorrect DECIMAL value: ''
2056
select repeat('hello', 18446744073709551616);
2057
repeat('hello', 18446744073709551616)
2060
Error 1292 Truncated incorrect DECIMAL value: ''
2061
Error 1292 Truncated incorrect DECIMAL value: ''
2062
Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
2063
select repeat('hello', -18446744073709551617);
2064
repeat('hello', -18446744073709551617)
2067
Error 1292 Truncated incorrect DECIMAL value: ''
2068
Error 1292 Truncated incorrect DECIMAL value: ''
2069
select repeat('hello', 18446744073709551617);
2070
repeat('hello', 18446744073709551617)
2073
Error 1292 Truncated incorrect DECIMAL value: ''
2074
Error 1292 Truncated incorrect DECIMAL value: ''
2075
Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
2079
select space(-4294967295);
2082
select space(4294967295);
2086
Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
2087
select space(-4294967296);
2090
select space(4294967296);
2094
Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
2095
select space(-4294967297);
2098
select space(4294967297);
2102
Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
2103
select space(-18446744073709551615);
2104
space(-18446744073709551615)
2107
Error 1292 Truncated incorrect DECIMAL value: ''
2108
Error 1292 Truncated incorrect DECIMAL value: ''
2109
select space(18446744073709551615);
2110
space(18446744073709551615)
2113
Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
2114
select space(-18446744073709551616);
2115
space(-18446744073709551616)
2118
Error 1292 Truncated incorrect DECIMAL value: ''
2119
Error 1292 Truncated incorrect DECIMAL value: ''
2120
select space(18446744073709551616);
2121
space(18446744073709551616)
2124
Error 1292 Truncated incorrect DECIMAL value: ''
2125
Error 1292 Truncated incorrect DECIMAL value: ''
2126
Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
2127
select space(-18446744073709551617);
2128
space(-18446744073709551617)
2131
Error 1292 Truncated incorrect DECIMAL value: ''
2132
Error 1292 Truncated incorrect DECIMAL value: ''
2133
select space(18446744073709551617);
2134
space(18446744073709551617)
2137
Error 1292 Truncated incorrect DECIMAL value: ''
2138
Error 1292 Truncated incorrect DECIMAL value: ''
2139
Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
2140
select rpad('hello', -1, '1');
2141
rpad('hello', -1, '1')
2143
select rpad('hello', -4294967295, '1');
2144
rpad('hello', -4294967295, '1')
2146
select rpad('hello', 4294967295, '1');
2147
rpad('hello', 4294967295, '1')
2150
Warning 1301 Result of rpad() was larger than max_allowed_packet (1048576) - truncated
2151
select rpad('hello', -4294967296, '1');
2152
rpad('hello', -4294967296, '1')
2154
select rpad('hello', 4294967296, '1');
2155
rpad('hello', 4294967296, '1')
2158
Warning 1301 Result of rpad() was larger than max_allowed_packet (1048576) - truncated
2159
select rpad('hello', -4294967297, '1');
2160
rpad('hello', -4294967297, '1')
2162
select rpad('hello', 4294967297, '1');
2163
rpad('hello', 4294967297, '1')
2166
Warning 1301 Result of rpad() was larger than max_allowed_packet (1048576) - truncated
2167
select rpad('hello', -18446744073709551615, '1');
2168
rpad('hello', -18446744073709551615, '1')
2171
Error 1292 Truncated incorrect DECIMAL value: ''
2172
Error 1292 Truncated incorrect DECIMAL value: ''
2173
select rpad('hello', 18446744073709551615, '1');
2174
rpad('hello', 18446744073709551615, '1')
2177
Warning 1301 Result of rpad() was larger than max_allowed_packet (1048576) - truncated
2178
select rpad('hello', -18446744073709551616, '1');
2179
rpad('hello', -18446744073709551616, '1')
2182
Error 1292 Truncated incorrect DECIMAL value: ''
2183
Error 1292 Truncated incorrect DECIMAL value: ''
2184
select rpad('hello', 18446744073709551616, '1');
2185
rpad('hello', 18446744073709551616, '1')
2188
Error 1292 Truncated incorrect DECIMAL value: ''
2189
Error 1292 Truncated incorrect DECIMAL value: ''
2190
Warning 1301 Result of rpad() was larger than max_allowed_packet (1048576) - truncated
2191
select rpad('hello', -18446744073709551617, '1');
2192
rpad('hello', -18446744073709551617, '1')
2195
Error 1292 Truncated incorrect DECIMAL value: ''
2196
Error 1292 Truncated incorrect DECIMAL value: ''
2197
select rpad('hello', 18446744073709551617, '1');
2198
rpad('hello', 18446744073709551617, '1')
2201
Error 1292 Truncated incorrect DECIMAL value: ''
2202
Error 1292 Truncated incorrect DECIMAL value: ''
2203
Warning 1301 Result of rpad() was larger than max_allowed_packet (1048576) - truncated
2204
select lpad('hello', -1, '1');
2205
lpad('hello', -1, '1')
2207
select lpad('hello', -4294967295, '1');
2208
lpad('hello', -4294967295, '1')
2210
select lpad('hello', 4294967295, '1');
2211
lpad('hello', 4294967295, '1')
2214
Warning 1301 Result of lpad() was larger than max_allowed_packet (1048576) - truncated
2215
select lpad('hello', -4294967296, '1');
2216
lpad('hello', -4294967296, '1')
2218
select lpad('hello', 4294967296, '1');
2219
lpad('hello', 4294967296, '1')
2222
Warning 1301 Result of lpad() was larger than max_allowed_packet (1048576) - truncated
2223
select lpad('hello', -4294967297, '1');
2224
lpad('hello', -4294967297, '1')
2226
select lpad('hello', 4294967297, '1');
2227
lpad('hello', 4294967297, '1')
2230
Warning 1301 Result of lpad() was larger than max_allowed_packet (1048576) - truncated
2231
select lpad('hello', -18446744073709551615, '1');
2232
lpad('hello', -18446744073709551615, '1')
2235
Error 1292 Truncated incorrect DECIMAL value: ''
2236
Error 1292 Truncated incorrect DECIMAL value: ''
2237
select lpad('hello', 18446744073709551615, '1');
2238
lpad('hello', 18446744073709551615, '1')
2241
Warning 1301 Result of lpad() was larger than max_allowed_packet (1048576) - truncated
2242
select lpad('hello', -18446744073709551616, '1');
2243
lpad('hello', -18446744073709551616, '1')
2246
Error 1292 Truncated incorrect DECIMAL value: ''
2247
Error 1292 Truncated incorrect DECIMAL value: ''
2248
select lpad('hello', 18446744073709551616, '1');
2249
lpad('hello', 18446744073709551616, '1')
2252
Error 1292 Truncated incorrect DECIMAL value: ''
2253
Error 1292 Truncated incorrect DECIMAL value: ''
2254
Warning 1301 Result of lpad() was larger than max_allowed_packet (1048576) - truncated
2255
select lpad('hello', -18446744073709551617, '1');
2256
lpad('hello', -18446744073709551617, '1')
2259
Error 1292 Truncated incorrect DECIMAL value: ''
2260
Error 1292 Truncated incorrect DECIMAL value: ''
2261
select lpad('hello', 18446744073709551617, '1');
2262
lpad('hello', 18446744073709551617, '1')
2265
Error 1292 Truncated incorrect DECIMAL value: ''
2266
Error 1292 Truncated incorrect DECIMAL value: ''
2267
Warning 1301 Result of lpad() was larger than max_allowed_packet (1048576) - truncated
2268
SET @orig_sql_mode = @@SQL_MODE;
2269
SET SQL_MODE=traditional;
2270
SELECT CHAR(0xff,0x8f USING utf8);
2271
CHAR(0xff,0x8f USING utf8)
2274
Error 1300 Invalid utf8 character string: 'FF8F'
2275
SELECT CHAR(0xff,0x8f USING utf8) IS NULL;
2276
CHAR(0xff,0x8f USING utf8) IS NULL
2279
Error 1300 Invalid utf8 character string: 'FF8F'
2280
SET SQL_MODE=@orig_sql_mode;
2281
select substring('abc', cast(2 as unsigned int));
2282
substring('abc', cast(2 as unsigned int))
2284
select repeat('a', cast(2 as unsigned int));
2285
repeat('a', cast(2 as unsigned int))
2287
select rpad('abc', cast(5 as unsigned integer), 'x');
2288
rpad('abc', cast(5 as unsigned integer), 'x')
2290
select lpad('abc', cast(5 as unsigned integer), 'x');
2291
lpad('abc', cast(5 as unsigned integer), 'x')
2293
create table t1(f1 longtext);
2294
insert into t1 values ("123"),("456");
2295
select substring(f1,1,1) from t1 group by 1;
2299
create table t2(f1 varchar(3));
2300
insert into t1 values ("123"),("456");
2301
select substring(f1,4,1), substring(f1,-4,1) from t2;
2302
substring(f1,4,1) substring(f1,-4,1)
2304
DROP TABLE IF EXISTS t1;
2306
`id` varchar(20) NOT NULL,
2307
`tire` tinyint(3) unsigned NOT NULL,
2310
INSERT INTO `t1` (`id`, `tire`) VALUES ('A', 0), ('B', 1),('C', 2);
2311
SELECT REPEAT( '#', tire ) AS A,
2312
REPEAT( '#', tire % 999 ) AS B, tire FROM `t1`;
2317
SELECT REPEAT('0', CAST(0 AS UNSIGNED));
2318
REPEAT('0', CAST(0 AS UNSIGNED))
2320
SELECT REPEAT('0', -2);
2323
SELECT REPEAT('0', 2);
2330
SELECT UNHEX('G') IS NULL;
2333
SELECT INSERT('abc', 3, 3, '1234');
2334
INSERT('abc', 3, 3, '1234')
2336
SELECT INSERT('abc', 4, 3, '1234');
2337
INSERT('abc', 4, 3, '1234')
2339
SELECT INSERT('abc', 5, 3, '1234');
2340
INSERT('abc', 5, 3, '1234')
2342
SELECT INSERT('abc', 6, 3, '1234');
2343
INSERT('abc', 6, 3, '1234')
2345
CREATE TABLE t1 (a INT);
2346
CREATE VIEW v1 AS SELECT CRC32(a) AS C FROM t1;
2347
INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
2348
SELECT CRC32(a), COUNT(*) FROM t1 GROUP BY 1;
2360
SELECT CRC32(a), COUNT(*) FROM t1 GROUP BY 1 ORDER BY 1;
2372
SELECT * FROM (SELECT CRC32(a) FROM t1) t2;
2384
CREATE TABLE t2 SELECT CRC32(a) FROM t1;
2386
Field Type Null Key Default Extra
2387
CRC32(a) int(10) unsigned YES NULL
2400
SELECT * FROM (SELECT * FROM v1) x;
2414
SELECT LOCATE('foo', NULL) FROM DUAL;
2417
SELECT LOCATE(NULL, 'o') FROM DUAL;
2420
SELECT LOCATE(NULL, NULL) FROM DUAL;
2423
SELECT LOCATE('foo', NULL) IS NULL FROM DUAL;
2424
LOCATE('foo', NULL) IS NULL
2426
SELECT LOCATE(NULL, 'o') IS NULL FROM DUAL;
2427
LOCATE(NULL, 'o') IS NULL
2429
SELECT LOCATE(NULL, NULL) IS NULL FROM DUAL;
2430
LOCATE(NULL, NULL) IS NULL
2432
SELECT ISNULL(LOCATE('foo', NULL)) FROM DUAL;
2433
ISNULL(LOCATE('foo', NULL))
2435
SELECT ISNULL(LOCATE(NULL, 'o')) FROM DUAL;
2436
ISNULL(LOCATE(NULL, 'o'))
2438
SELECT ISNULL(LOCATE(NULL, NULL)) FROM DUAL;
2439
ISNULL(LOCATE(NULL, NULL))
2441
SELECT LOCATE('foo', NULL) <=> NULL FROM DUAL;
2442
LOCATE('foo', NULL) <=> NULL
2444
SELECT LOCATE(NULL, 'o') <=> NULL FROM DUAL;
2445
LOCATE(NULL, 'o') <=> NULL
2447
SELECT LOCATE(NULL, NULL) <=> NULL FROM DUAL;
2448
LOCATE(NULL, NULL) <=> NULL
2450
CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, a varchar(10), p varchar(10));
2451
INSERT INTO t1 VALUES (1, 'foo', 'o');
2452
INSERT INTO t1 VALUES (2, 'foo', NULL);
2453
INSERT INTO t1 VALUES (3, NULL, 'o');
2454
INSERT INTO t1 VALUES (4, NULL, NULL);
2455
SELECT id, LOCATE(a,p) FROM t1;
2461
SELECT id, LOCATE(a,p) IS NULL FROM t1;
2462
id LOCATE(a,p) IS NULL
2467
SELECT id, ISNULL(LOCATE(a,p)) FROM t1;
2468
id ISNULL(LOCATE(a,p))
2473
SELECT id, LOCATE(a,p) <=> NULL FROM t1;
2474
id LOCATE(a,p) <=> NULL
2479
SELECT id FROM t1 WHERE LOCATE(a,p) IS NULL;
2484
SELECT id FROM t1 WHERE LOCATE(a,p) <=> NULL;
2490
SELECT SUBSTR('foo',1,0) FROM DUAL;
2493
SELECT SUBSTR('foo',1,CAST(0 AS SIGNED)) FROM DUAL;
2494
SUBSTR('foo',1,CAST(0 AS SIGNED))
2496
SELECT SUBSTR('foo',1,CAST(0 AS UNSIGNED)) FROM DUAL;
2497
SUBSTR('foo',1,CAST(0 AS UNSIGNED))
2499
CREATE TABLE t1 (a varchar(10), len int unsigned);
2500
INSERT INTO t1 VALUES ('bar', 2), ('foo', 0);
2501
SELECT SUBSTR(a,1,len) FROM t1;
2506
CREATE TABLE t1 AS SELECT CHAR(0x414243) as c1;
2507
SELECT HEX(c1) from t1;
2511
CREATE VIEW v1 AS SELECT CHAR(0x414243) as c1;
2512
SELECT HEX(c1) from v1;