MySQL模糊查詢

2021-10-07 21:51:14 字數 747 閱讀 7576

like:進行資料模糊查詢

1、%: 匹配0次或多次

select * from student where name like '張%』;#查詢姓張的學生資訊

select * from student where name like '%李%』;#查詢姓名中含有「李」字的學生資訊

2、_ : 只能匹配一次

select * from student where name like '張_』;#查詢兩個字的張姓學生資訊

3、escape:取消%或_字元的萬用字元特性

#查詢姓名中含有%字元的學生資訊

select * from student where name like '%#%%' escape 『#』

#查詢姓名中含有%字元的學生資訊

select * from student where name like '%$_%' escape 『$』

#查詢姓名以%%結尾的學生資訊

select * from student where name like '%_%_%' escape '_』;

注意: escape後面單引號中只能是單個字元;

escape後面可以是字母、#、$、,、\等字元;

mysql模糊查詢 MYSQL模糊查詢

mysql提供標準的sql模式匹配,以及一種基於象unix實用程式如vi grep和sed的擴充套件正規表示式模式匹配的格式。一 sql模式 sql的模式匹配允許你使用 匹配任何單個字元,而 匹配任意數目字元 包括零個字元 在 mysql中,sql的模式預設是忽略大小寫的。下面顯示一些例子。注意在你...

mysql模糊查詢索引 MySQL模糊查詢全文索引

全文索引 mysql front dump 2.5 host localhost database test server version 4.0.12 nt log table structure for table t3 create table t3 name char 12 not null...

mysql 正反模糊查詢 mysql模糊查詢

mysql 使用內建函式進行模糊查詢 locate,position,instr,find in set 1 locate substr str,pos 方法 2 position substr in field 方法 3 instr str substr 方法 4 find in set str1...