mysql数据库简单练习(重点查询,commoditytype表!) 1.查询所有c-type=1的商品 select*from commodity where c_type=1; 2.查询所有c_type=2,且进价小于100的商品 select*from commodity where c_type=2 and c_inprice<100; 3.查询所有c_type=3且进价小于100且售价为非空的商品 select*from commodity where c_type=3 and c_inprice<100 and c_outprice is not null; 4.查询所有进价大于20且小于80的商品 select*from commodity where c_inprice>20 and c_inprice<80; 5.查询所有进价大于等于20且小于等于80的商品 select*from commodity where c_inprice between 20 and 80; 6.查询所有库存为5或者10或者15的商品 select*from commodity where c_num in (5,10,15); 7.查询所有商品名称中带书关键字的商品 select*from commodity where c_name like ‘%书%’; 8.查询商品库存最大的前5件商品 select*from commodity order by c_num desc limit 5; 9.查询商品库存最大的第6至20件商品 select*from commodity order by c_num desc limit 5,15; 10.查询一共有多少库存 select sun(c_num) from commodity; 11.查询每种商品的平均进价 select c_type,avg(c_inprice) from commodity group by c_type; 12.查询每种商品的数量 select c_type,count(*) from commodity group by c_type; 13.将所有商品的库存数量都+10 update commodity set c_num=c_num+10; 14.删除没有售出价格的所有商品 delete from commodity where c_outprice is null;