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)
本文介绍了MySQL中使用LIKE和NOT LIKE进行模糊查询的方法。通过具体示例展示了如何查询包含特定字符的记录,排除特定字符的记录,以及结合其他条件进行复合查询。
998

被折叠的 条评论
为什么被折叠?



