📄 func_like.test
字号:
## Test of like#--disable_warningsdrop table if exists t1;--enable_warningscreate table t1 (a varchar(10), key(a));insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test");explain select * from t1 where a like 'abc%';explain select * from t1 where a like concat('abc','%');select * from t1 where a like "abc%";select * from t1 where a like concat("abc","%");select * from t1 where a like "ABC%";select * from t1 where a like "test%";select * from t1 where a like "te_t";## The following will test the Turbo Boyer-Moore code#select * from t1 where a like "%a%";select * from t1 where a like "%abcd%";select * from t1 where a like "%abc\d%";drop table t1;create table t1 (a varchar(10), key(a));## Bug #2231#insert into t1 values ('a'), ('a\\b');select * from t1 where a like 'a\\%' escape '#';select * from t1 where a like 'a\\%' escape '#' and a like 'a\\\\b';## Bug #4200: Prepared statement parameter as argument to ESCAPE#prepare stmt1 from 'select * from t1 where a like \'a\\%\' escape ?';set @esc='#';execute stmt1 using @esc; deallocate prepare stmt1;drop table t1;## Bug #2885: like and datetime#create table t1 (a datetime);insert into t1 values ('2004-03-11 12:00:21');select * from t1 where a like '2004-03-11 12:00:21';drop table t1;## Test like with non-default character set#SET NAMES koi8r;CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET koi8r);INSERT INTO t1 VALUES ('瀑琢'),('尜琢'),('迄琢'),('瀑髁'),('瀑揍'),('纟麽');INSERT INTO t1 VALUES ('瀑琢幸咸闹'),('尜琢幸咸闹'),('迄琢幸咸闹'),('瀑髁幸咸闹');INSERT INTO t1 VALUES ('瀑揍幸咸闹'),('瀑琢鹨咸闹'),('瀑琢序咸闹'),('瀑琢幸锾闹');INSERT INTO t1 VALUES ('瀑琢幸响闹'),('瀑琢幸咸渲'),('瀑琢幸咸啮'),('纟麽痱镬漩');SELECT * FROM t1 WHERE a LIKE '%迄琢%';SELECT * FROM t1 WHERE a LIKE '%迄
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -