赞
踩
@爱学习的阿朵
drop table websites
create table websites
(
id varchar(30),
name varchar(30),
url varchar(30),
alexa varchar(30),
country varchar(30));
----------------------------------------------------------------------------------------
INSERT INTO websites VALUES ('1', 'Google', 'https://www.google.cm/', '1', 'USA');
INSERT INTO websites VALUES('2', '淘宝', 'https://www.taobao.com/', '13', 'CN');
INSERT INTO websites VALUES('3', '菜鸟教程', 'http://www.runoob.com/', '4689', 'CN');
INSERT INTO websites VALUES('4', '微博', 'http://weibo.com/', '20', 'CN');
INSERT INTO websites VALUES('5', 'Facebook', 'https://www.facebook.com/', '3', 'USA');
select * from websites
create table access_log(
aid varchar(30),
site_id varchar(30),
counts varchar(30),
dates varchar(30));
INSERT INTO access_log VALUES('1','1','45','2016-05-10');
INSERT INTO access_log VALUES('2','3','100','2016-05-13');
INSERT INTO access_log VALUES('3','1','230','2016-05-14');
INSERT INTO access_log VALUES('4','2','10','2016-05-14');
INSERT INTO access_log VALUES('5','5','205','2016-05-14');
INSERT INTO access_log VALUES('6','4','13','2016-05-15');
INSERT INTO access_log VALUES('7','3','220','2016-05-15');
INSERT INTO access_log VALUES('8','5','545','2016-05-16');
INSERT INTO access_log VALUES('9','3','201','2016-05-17');
select * from access_log
select *
from access_log a
join websites w on w.id=a.aid
select * from websites w
join access_log a on w.id=a.aid
select * from websites w
left join access_log a on w.id=a.aid
select * from access_log a
left join websites w on w.id=a.aid
select count(country)from websites
group by country
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。