func_like.result 1.04 KB
Newer Older
1 2 3
drop table if exists t1;
create table t1 (a varchar(10), key(a));
insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test");
4 5 6 7 8 9
explain select * from t1 where a like 'abc%';
table	type	possible_keys	key	key_len	ref	rows	Extra
t1	range	a	a	11	NULL	1	Using where; Using index
explain select * from t1 where a like concat('abc','%');
table	type	possible_keys	key	key_len	ref	rows	Extra
t1	range	a	a	11	NULL	1	Using where; Using index
10
select * from t1 where a like "abc%";
11 12 13
a
abc
abcd
14 15 16 17
select * from t1 where a like concat("abc","%");
a
abc
abcd
18
select * from t1 where a like "ABC%";
19
a
20 21
abc
abcd
22
select * from t1 where a like "test%";
23
a
24
test
25
select * from t1 where a like "te_t";
26 27
a
test
28 29 30 31 32 33 34 35 36 37 38
select * from t1 where a like "%a%";
a
a
abc
abcd
select * from t1 where a like "%abcd%";
a
abcd
select * from t1 where a like "%abc\d%";
a
abcd
39
drop table t1;
40 41 42 43 44
create table t1 (a varchar(10), key(a));
insert into t1 values ('a'), ('a\\b');
select * from t1 where a like 'a\\%' escape '#';
a
a\b
45 46 47
select * from t1 where a like 'a\\%' escape '#' and a like 'a\\\\b';
a
a\b
48
drop table t1;