一,mysql加载Sakila样例数据库
- 下载:http://downloads.mysql.com/docs/sakila-db.tar.gz
- 解压:将解压的文件放入目录中
- 在mysql中使用以下命令:
-
> source E:/sakila-schema.sql;(此处为自己的安装路径)
-
>source E:/sakila-data.sql;(注意路径上的名称为英文,改成“\”)
- select count(*) from custormer;显示几百条记录就说明导入成功了
二,获取数据
- 利用SQL语句,将customer_list表和payment表连接,从而得到各个城市每个消费者的消费额
- select city,country from country,city,customer where country.country_id=city.country_id and city.city_id=customer.address_id;