2001-09-28 07:05:54 +02:00
|
|
|
drop table if exists t1;
|
|
|
|
create table t1 (a varchar(10), key(a));
|
|
|
|
insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test");
|
2003-03-02 14:07:32 +01:00
|
|
|
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
|
2001-09-28 07:05:54 +02:00
|
|
|
select * from t1 where a like "abc%";
|
2000-12-28 02:56:38 +01:00
|
|
|
a
|
|
|
|
abc
|
|
|
|
abcd
|
2003-03-02 14:07:32 +01:00
|
|
|
select * from t1 where a like concat("abc","%");
|
|
|
|
a
|
|
|
|
abc
|
|
|
|
abcd
|
2001-09-28 07:05:54 +02:00
|
|
|
select * from t1 where a like "ABC%";
|
2000-12-28 02:56:38 +01:00
|
|
|
a
|
2001-09-14 01:54:33 +02:00
|
|
|
abc
|
|
|
|
abcd
|
2001-09-28 07:05:54 +02:00
|
|
|
select * from t1 where a like "test%";
|
2001-09-14 01:54:33 +02:00
|
|
|
a
|
2000-12-28 02:56:38 +01:00
|
|
|
test
|
2001-09-28 07:05:54 +02:00
|
|
|
select * from t1 where a like "te_t";
|
2000-12-28 02:56:38 +01:00
|
|
|
a
|
|
|
|
test
|
2002-05-17 15:45:00 +02:00
|
|
|
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
|
2001-09-28 07:05:54 +02:00
|
|
|
drop table t1;
|
2003-12-30 16:23:38 +01:00
|
|
|
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
|
2004-01-08 09:24:36 +01:00
|
|
|
select * from t1 where a like 'a\\%' escape '#' and a like 'a\\\\b';
|
|
|
|
a
|
|
|
|
a\b
|
2003-12-30 16:23:38 +01:00
|
|
|
drop table t1;
|