同时查询多条数据:
select * from students where id =1 or id=2 or id=3;
select * from students where id in (1,2,3);
select * from students where id not in(2,3);
同时查询数据+ 排序:
select * from students where id in (2,3) order by python_grade ASC;
分组查询: group by :
create table goods( id bigint(20) not null auto_increment primary key , goodName varchar(40) , goodCategory varchar(20) );
insert into goods (goodName, goodCategory ) values('apple','phone') ,('oppo' ,'phone' ),('mac' ,'computer' ),('lenovo' ,'computer'),('vivo','phone');
查询goods商品的种类:
select goodCategory from goods group by goodCategory;
查询goods商品是否存在类型
gruop by +having
select goodCategory from goods group by goodCategory having goodCategory='phone';
分页:(limit 起始下标,每页显示数据量)
goods 表中有7条数据,每页显示3条,一共可以显示3页;
获取第一页数据: select * from goods limit 0,3;
获取第二页数据: select * from goods limit 3,3;
获取第三页数据:select * from goos limit 6,3;
select * from goods limit (pageNumber-1)*pageSize,pageSize;