mysql模糊查詢語句like與not like的使用與區別


mysql模糊查詢like的用法

查詢user表中姓名中有“王”字的:

select * from user where name like '%王%'

mysql模糊查詢not like的用法

查詢user表中姓名中沒有“王”字的:

select * from user where name not like '%王%'

查詢user表中地址在上海姓名中沒有“王”字和所有姓名為空的:

select * from user where adress =‘上海’ and name not like '%王%' or name is null

查詢user表中地址在上海姓名中沒有“王”字和地址在上海姓名為空的:

select * from user where adress =‘上海’ and (name not like '%王%' or name is null)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM