mysql 模糊查詢示例

2021-09-25 12:05:49 字數 794 閱讀 1698

#查詢所有姓劉的學生的姓名、學號和性別

select sname,sno,s*** from student where sname like '劉%';

-------------

#查詢姓「歐陽」且全名為三個漢字的學生的姓名

select sname from student where sname like '歐陽_';

-- 注意:資料庫字符集為ascii時乙個漢字需要兩個 _ ; 當字符集為gbk是只需要乙個

--------------

#查詢名字中第二個字為「陽」的學生的姓名和學號

select sname,sno from student where sname like '%陽%';

-------------

#查詢所有不姓劉的學生的姓名、學號和性別

select sname,sno,s*** from student where sname not like '劉%';

-------------

#查詢db_design課程的課程號和學分

select cno,ccredit from course where cname like 'db\_design' escape '\\';

-------------

#查詢以「db_」開頭,且倒數第三個字元為i的課程的詳細情況

select * from course where cname like 'db\_%' 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...