select * from goods where goodsid
in(select goodsid from orderdetails where orderid
in(select orderid from (select orderid from orders ORDER BY orderdate desc LIMIT 3) as a));
//最新外卖显示(显示外卖商品信息表的全部信息)
SELECT a.title,a.unitprice,a.discount,a.descrioption
FROM goods a,orderdetails b
WHERE a.goodsid=b.goodsid and qty=(SELECT max(qty) FROM orderdetails);
//畅销外卖显示
SELECT * FROM goods WHERE discount<1;
//活动外卖显示
SELECT * FROM goods WHERE title LIKE '%大盘鸡%';
//按照某关键字雨外卖标题的匹配查询外卖信息并显示
SELECT b.cateName,a.title,a.unitprice,a.discount,a.descrioption
FROM goods a INNER JOIN category b WHERE a.cateid=b.cateid GROUP BY cateName;
//按照外卖类型分类显示外卖信息
SELECT * FROM goods WHERE goodsid=2;
//用户点击某一个外卖,显示该外卖的详细信息
UPDATE goods SET like_title='1' WHERE goodsid=2;
//用户可以选择自己喜欢的外卖,放入购物车,(喜欢的放入购物车显示为‘1’)
SELECT * FROM goods WHERE like_title=1 and
EXISTS(SELECT * FROM customers WHERE custName='黄雅玲' AND loginpwd=234654);
//用户可以对购物车中的外卖下订单,下订单前需要先登录(输入用户名和密码)
SELECT * FROM orders
WHERE custid in(SELECT custid FROM customers
WHERE custName='黄雅玲' AND loginpwd=234654);
//用户登录可以查询自己的订单的情况,包括是否发货、商品在途情况、商品签收情况。
INSERT INTO goods(title,unitprice,packingexpense) VALUE('小鸡炖蘑菇','30.00','2');
//外卖基本信息录入
UPDATE goods SET roat=2 WHERE goodsid=2;
//外卖信息修改
UPDATE goods SET discount=0.75 WHERE goodsid=2;
//外卖销售折扣设置
SELECT * FROM orders WHERE orderstatus='已付款';
//订单发货
SELECT * FROM orders WHERE orderno=20110508001;
//订单信息查询
UPDATE customers SET account=1000 WHERE custname='黄雅玲';
//用户账户充值
UPDATE customers SET loginpwd='234654' WHERE custname='黄雅玲';
//用户密码修改
来源:https://www.cnblogs.com/kanyidao/p/11637505.html