CREATE DATABASE IF NOT EXISTS test DEFAULT CHARSET utf8;
USE test;
CREATE TABLE IF NOT EXISTS websites2(id INT PRIMARY KEY AUTO_INCREMENT,
NAME VARCHAR(50) NOT NULL,
url VARCHAR(50) NOT NULL,
alexa INT NOT NULL COMMENT '网站排名',
country VARCHAR(50) NOT NULL
);
INSERT INTO websites2(NAME,url,alexa,country)VALUES
("google",'http://www.google.com',1,'usa'),
("淘宝",'http://www.taobao.com',13,'usa'),
("菜鸟",'http://www.runoob.com',4689,'usa'),
("微博",'http://www.weibo.com',20,'usa'),
("Facebook",'http://www.facebook.com',3,'usa'),
("StackOverflow",'http://www.stackoverflow.com',0,'usa'),
("百度",'http://www.baidu.com',4,'usa');
SELECT * FROM websites2
SELECT st.*,sc.*,su.* FROM student st
INNER JOIN score sc ON st.no=sc.no
LEFT JOIN sub su ON sc.subno=su.subno
WHERE st.no > 1;
SELECT e.emp_ name, e.salary, e.dept_ id, d. dept_ nameFROM (
SELECT emp_ name , dept_ id, salary FROM empWHERE dept_ id >= 2
AND salary > 5000
)e
LEFT JOIN dept d
ON e.dept_ id = d.id~ ;