SELECT g.goods_id AS goodsId, g.goods_name AS goodsName, SUM(t.trading_number) AS tradingNumber,
COUNT(t.trading_id) AS times, g.selling_price AS sellingPrice, g.cost_price AS costPrice
FROM goods_list g
LEFT JOIN trading_info t ON(t.trading_goods_id = g.goods_id)
GROUP BY g.goods_id
COUNT(t.trading_id) AS times, g.selling_price AS sellingPrice, g.cost_price AS costPrice
FROM goods_list g
LEFT JOIN trading_info t ON(t.trading_goods_id = g.goods_id)
GROUP BY g.goods_id
2018-01-16
CREATE TABLE buyer(
userid VARCHAR(20) NOT NULL COMMENT'买家ID',
name VARCHAR(20) NOT NULL COMMENT '买家姓名',
age INT(3) DEFAULT NULL COMMENT '买家年龄',
sex VARCHAR(2) DEFAULT NULL COMMENT '买家性别',
area VARCHAR(30) DEFAULT NULL COMMENT '买家所在地区',
tel INT(16) DEFAULT NULL COMMENT '买家电话');
userid VARCHAR(20) NOT NULL COMMENT'买家ID',
name VARCHAR(20) NOT NULL COMMENT '买家姓名',
age INT(3) DEFAULT NULL COMMENT '买家年龄',
sex VARCHAR(2) DEFAULT NULL COMMENT '买家性别',
area VARCHAR(30) DEFAULT NULL COMMENT '买家所在地区',
tel INT(16) DEFAULT NULL COMMENT '买家电话');
CREATE TABLE goods(
goods_id VARCHAR(255) NOT NULL COMMENT'商品ID',
goods_name VARCHAR(255) DEFAULT NULL COMMENT '商品名称',
cost_price DOUBLE DEFAULT NULL COMMENT '成本价',
selling_price DOUBLE DEFAULT NULL COMMENT '售价',
manufacturer VARCHAR(255) DEFAULT NULL COMMENT '制造商');
goods_id VARCHAR(255) NOT NULL COMMENT'商品ID',
goods_name VARCHAR(255) DEFAULT NULL COMMENT '商品名称',
cost_price DOUBLE DEFAULT NULL COMMENT '成本价',
selling_price DOUBLE DEFAULT NULL COMMENT '售价',
manufacturer VARCHAR(255) DEFAULT NULL COMMENT '制造商');