Selecttop3*from vspace.i_goods where goods_id notin(Selecttop(4*3) goods_id from vspace.i_goods
);Select*from vspace.i_goods limit(4*3),3;select t.*from(select rownum num,*from vspace.i_goods where rownum <=(5*3)) t where num >(4*3);
从商品信息列表中查询包含”五花肉”的商品标题信息,并从标题中截取出”五花肉”这个 字符串
select*from vspace.i_goods where goods_title like'%五花肉%';select substring('猪五花肉',2,3);
请使用随机数函数得到任意一个随机三位数
select floor(rand()*(999-100+1)+100);
查询最近 10 天的订单信息
select*from vspace.i_order where datediff (DD,order_date,curdate)<=10;
查询统计最近一个月的总销售额
selectsum(sum_price)from vspace.i_order where datediff (DD,order_date,curdate)<30;
使用多表内联接(两种方式)查询用户手机号码、密码、注册时间、昵称信息 *表中并没有昵称信息奥 *
select u.phone,u.password,b.reg_date,b.phone,
u.phone,b.phone
from vspace.i_user u innerjoin vspace.i_basic b
on u.phone=b.phone;select u.phone,u.password,b.reg_date,b.phone,
u.phone,b.phone
from vspace.i_user u,vspace.i_basic b
where u.phone=b.phone;
查询用户手机号、昵称、下单时间、订单商品标题、商品数量、总价等信息 依然没有昵称
select b.phone,g.goods_title,g.ammount,g.price
from vspace.i_basic b,vspace.i_cart c,vspace.i_goods g
where b.phone=c.phone and g.goods_id=c.goods_id
查询显示所有类型的商品,如果某个类型没有对应的商品则显示为空
select*from vspace.i_goods g
leftouterjoin vspace.i_category c
on g.category_id=c.category_id
请用子查询查找年龄最小的用户的基本信息
select*from vspace.i_basic where birthday in(selectmax(birthday)from vspace.i_basic
);
请用子查询查找所有商品以及该商品所属的一级类型名称
select goods_id,goods_title,(select category_name from vspace.i_category where
category_id=(select parent_id from vspace.i_category
where category_id=g.category_id
)) 一级类型名称 from vspace.i_goods g;
select o.order_id,b.id_card,(select goods_title from vspace.i_goods where goods_id=o.goods_id),
o.ammount,o.sum_price from vspace.i_order o,vspace.i_basic b
where o.phone=b.phone limit(4*7),7;