2020年12月11日
摘要: 一、count() 优化 误区:myisam的count()非常快 答: 是比较快,.但仅限于查询表的”所有行”比较快, 因为Myisam对行数进行了存储.;一旦有条件的查询, 速度就不再快了.尤其是where条件的列上没有索引. 例如:想查询id>=100的商家有多少? select count( 阅读全文
posted @ 2020-12-11 16:02 鸥海 阅读(338) 评论(0) 推荐(0) 编辑
摘要: 题: 查询有商品的栏目. 按上面的理解,我们用join来操作,如下: mysql> select c.cat_id,cat_name from ecs_category as c inner join goods as g on c.cat_id=g.cat_id group by cat_name 阅读全文
posted @ 2020-12-11 14:58 鸥海 阅读(486) 评论(0) 推荐(0) 编辑
摘要: 题: 在ecshop商城表中,查询6号栏目的商品, (注:6号是一个大栏目) 最直观的方法: mysql> select goods_id,cat_id,goods_name from goods where cat_id in (select cat_id from ecs_category wh 阅读全文
posted @ 2020-12-11 14:44 鸥海 阅读(187) 评论(0) 推荐(0) 编辑