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