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%'

浙公网安备 33010602011771号