mysql增删改查——条件查询+模糊查询

条件查询一般是

= 等于

>大于

<小于

>=大于等于

<=小于等于

<>区间

between and区间

or并且

and或者

in包含

like模糊查询

实例,现在一张mysql表,表名app01_book,详细数据如下图所示

 

 

 1,查询价格为50的书信息(书信息包括书名+书价格+书作者)

select name,price,author_name from app01_book where price = 50;

2,查询价格大于30的书信息(书信息包括书名+书价格+书作者)

 

 

select name,price,author_name from app01_book where price>30;

3,查询价格大于等于30的书信息(书信息包括书名+书价格+书作者)

select name,price,author_name from app01_book where price>=30;

4,查询价格小于30的书信息(书信息包括书名+书价格+书作者)

select name,price,author_name from app01_book where price<30;

5,查询价格小于等于30的书信息(书信息包括书名+书价格+书作者)

select name,price,author_name from app01_book where price<=30;

6,查询价格范围在33元到51元的书信息(书信息包括书名+书价格+书作者)

select name,price,author_name from app01_book where price between 33 and 51;

7,查询书作者名字为wangchengyang或者为tomson的书信息(书信息包括书名+书价格+书作者)

select name,price,author_name from app01_book where author_name = 'tomson' or author_name = 'wangchengyang';

8,查询书价格为50的书并且编号为666的书信息(书信息包括书名+书价格+书作者)

select name,price,author_name from app01_book where price = 50 and is_null = 666;

模糊查询

1,查询书作者姓名以z开头的作者姓名

select author_name from app01_book where author_name like 'z%';

2,查询书作者姓名以g结尾的作者姓名

select author_name from app01_book where author_name like 'g%';

3,查询书作者姓名第二位为h的作者姓名

select author_name from app01_book where author_name like '_h%'

4,查询书作者姓名第三位为m的作者姓名

select author_name from app01_book where author_name like '__m%'

 


__EOF__

本文作者汪成阳
本文链接https://www.cnblogs.com/wangchengyang/p/15157817.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角推荐一下。您的鼓励是博主的最大动力!
posted @   非非非常帅的辰  阅读(335)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
点击右上角即可分享
微信分享提示

喜欢请打赏

扫描二维码打赏

支付宝打赏