首先来造一部分数据,表mygoods为商品表,cat_id为分类id,goods_id为商品id,status为商品当前的状态位(1:有效,0:无效). CREATE TABLE `mygoods` ( `goods_id` ) unsigned NOT NULL AUTO_INCREMENT, `cat_id` ) ', `price` ) ', `status` ) ', PRIMARY KEY (`goods_id`), KEY `icatid` (`cat_id`) ) ENGINE=I