SELECT * FROM orders ORDER BY orderdate DESC; 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 discount<1; SELECT * FROM goods WHERE title LIKE '%汉堡%'; SELECT title as '名称',descrioption as '口味',cateid as '编号'FROM goods GROUP BY title,descrioption,cateid; SELECT * FROM goods WHERE cateid=1; UPDATE goods SET gwc=1; SELECT * FROM goods WHERE gwc=1 AND EXISTS(SELECT * FROM customers WHERE custname='黄药师'); SELECT * FROM orders WHERE orderno=20110508002 AND EXISTS(SELECT * FROM customers WHERE custname='黄药师'); INSERT goods(goodsid,title,unitprice,discount,cateid,storeid,roat,descrioption,packingexpense)
VALUES (1,'米饭',10,0.75,8,2,3,'微辣',2); UPDATE goods SET descrioption='麻辣'; UPDATE goods SET discount=0.75 WHERE goodsid='6'; SELECT * FROM orders WHERE orderstatus IN ('已发货'); SELECT a.orderid,a.orderno,a.custname,a.custphone,a.custaddress,a.invoicecontent,a.orderstatus,b.goodsid,b.qty,b.unitprice,c.loginpwd,c.account FROM orders a INNER JOIN orderdetails b ON a.orderno=b.orderid INNER JOIN customers c ON a.custid=c.custid; UPDATE customers SET account=1000 WHERE custid='2'; UPDATE customers SET loginpwd=2312 WHERE custid='2'; 179页 SELECT goodsid,title,unitprice,discount,cateid,storeid,roat,descrioption,packingexpense FROM goods; SELECT * FROM goods WHERE cateid=(SELECT cateid FROM category WHERE cateName='川湘菜'); SELECT * FROM goods WHERE title LIKE '%大盘鸡%'; SELECT * FROM goods WHERE roat=5 AND descrioption='麻辣'; SELECT goodsid,title,unitprice,discount,cateid,storeid,roat,descrioption,packingexpense FROM goods WHERE goodsid=24; SELECT * FROM goods WHERE goodsid in(SELECT goodsid FROM orderdetails ORDER BY qty DESC LIMIT 10); SELECT * FROM orders WHERE custname='黄雅玲'; SELECT * FROM goods WHERE cateid=6 and storeid IN(SELECT storeid FROM store WHERE personspending>=30 and personspending<=50); SELECT c.cateName,a.title,b.unitprice as 销售总额 FROM goods a,orderdetails b,category c WHERE a.goodsid=b.goodsid and a.cateid=c.cateid; SELECT sum(unitprice) as 销售总额 FROM orderdetails; SELECT c.cateName as 外卖类型,b.qty as 销售数量,a.title as 外卖商品 FROM goods a,orderdetails b,category c WHERE a.goodsid=b.goodsid and a.cateid=c.cateid; SELECT * FROM goods WHERE storeid=4; 180页 SELECT c.orderdate,a.title,b.qty,a.unitprice FROM goods a,orderdetails b,orders c WHERE a.goodsid=b.goodsid and b.orderid=c.orderid and orderstatus='已收货'; SELECT custname,custaddress,custphone FROM orders; SELECT count(phone) as 人数 FROM customers WHERE phone LIKE '188%'; SELECT count(custaddress) as 人数 FROM orders WHERE custaddress like '%二七广场%'; SELECT custname,custphone FROM orders WHERE orderprice=(SELECT max(orderprice) FROM orders); SELECT d.custname,d.custaddress,a.title,a.unitprice,b.qty,c.cateName FROM goods a,orderdetails b,category c,orders d WHERE a.cateid=c.cateid and b.orderid=d.orderid and b.goodsid=a.goodsid and custaddress='北京市和平东路四段32号'; SELECT d.custname,d.custaddress,a.title,a.unitprice,b.qty,c.cateName FROM goods a,orderdetails b,category c,orders d WHERE a.cateid=c.cateid and b.orderid=d.orderid and b.goodsid=a.goodsid and custaddress='北京市和平东路四段32号' ORDER BY a.unitprice DESC; SELECT b.cateName FROM goods a,category b WHERE a.cateid=b.cateid and a.unitprice=(SELECT max(unitprice) FROM goods); SELECT orderdate,max(orderprice) as 最高金额 FROM orders; SELECT b.cateName,count(title) as 数量 FROM goods a,category b WHERE a.cateid=b.cateid GROUP BY a.title; SELECT custname FROM orders WHERE orderprice=(SELECT max(orderprice) FROM orders); SELECT MAX(unitprice)AS 最高价格 FROM goods; SELECT MIN(unitprice)AS 最低价格 FROM goods;SELECT AVG(untiprice)AS 平均价格 FROM goods;