任务一
#Table person
---------------创建表格---------------
CREATE TABLE person(
PersonId int NOT NULL AUTO_INCREMENT,
FirstName varchar(32) NOT NULL,
LastName varchar(32) NOT NULL,
PRIMARY KEY (PersonId)
)
---------------插入数据---------------
INSERT person VALUES (1,'Dai','JingTian');
INSERT person VALUES (2,'YYY','KKK');
INSERT person VALUES (3,'MMM','PPP');
#Table person
---------------创建表格---------------
CREATE TABLE Address(
AddressId int NOT NULL AUTO_INCREMENT,
PersonId int NOT NULL ,
City varchar(32) NOT NULL,
State varchar(32) NOT NULL,
PRIMARY KEY (AddressId)
);
---------------插入数据---------------
INSERT Address VALUES (1,2,'BeiJing','China');
INSERT Address VALUES (2,3,'Xinyang','Henan');
INSERT Address VALUES (3,1,'Tongzhou','HeBei');
SELECT FirstName,LastName,City,State FROM
person LEFT JOIN Address
ON person.PersonId = Address.PersonId
任务二
SELECT * FROM email WHERE
id in (SELECT min(ID) FROM email
GROUP BY Email)