首页 > 代码库 > 网易-数据库

网易-数据库

技术分享

1、

SELECT g.`name`,DISTINCT(s.goods_id) from shoppinglist s,goods g
WHERE s.goods_id=g.id

错误

正确是:

SELECT DISTINCT(s.goods_id),g.`name` from shoppinglist s,goods g
WHERE s.goods_id=g.id

2、

select c.`name`,g.`name`, FORMAT(s.number/g.unit_price , 2)from customer c,shoppinglist s,goods g
where c.id=s.customer_id and s.goods_id=g.id

3、

SELECT * from customer c where c.date>‘2012-11-1‘ order by c.id asc

4、

SELECT c.`name` from customer c,shoppinglist s where c.id=s.customer_id GROUP BY s.customer_id
HAVING sum(s.number)>=50

 

网易-数据库