配合使用like敘述,可以找出資料中符合的數字或字串,還可使用「%」及「_」
搜尋時,若是數字可直接書寫,若是字串或使用「%」及「_」皆要加單引號代表字串
(1)、like使用數字
範例:列出符合英文科為82分的資料
指令:select * from exam where eng like 82;

(2)、like使用字串要加單引號('')
範例:列出符合姓名cat的資料
指令:select * from exam where name like 'cat';

(3)、like與萬用字元「%」的使用
「%」:可代表零個以上的字元,搜尋時可放在字串前後使用
範例:列出符合英文科分數字尾為2的資料
指令:select * from exam where eng like '%2';

(4)、like與底線「_」的使用
「_」:只代表至少至多一個字元,搜尋時可放在字串前後使用
當然也可用多個底線,二個__代表二個字元,三個___代表三個,類推...
範例:列出符合有科目在80~89分的資料
指令:
select * from exam
where cht like '8_'
or eng like '8_'
or math like '8_'; |

(5)、也可搜尋中文字串,如:「'小%'」
|