今天用mysql進行模糊查詢時,意外的發現mysql的模糊查詢是不區分字母的大小寫的
原始碼:
select r.*, u.name, u.id
from tb_report r,
tb_user u
where r.report_user = u.id
and r.isdelete = 0
and r.report_status = 1
and (r.report_title like '%A%'
or u.name like '%A%')
複製程式碼

select r.*, u.name, u.id
from tb_report r,
tb_user u
where r.report_user = u.id
and r.isdelete = 0
and r.report_status = 1
and (r.report_title like binary '%A%'
or u.name like binary '%A%')
複製程式碼

binary
這個關鍵字,它可以讓mysql的模糊查詢以區分大小寫的形式進行。