MySQL服务器端下载官方网址:https://dev.mysql.com/downloads/installer/
Navicat客户端下载网址:https://navicat.com.cn/download/navicat-premium
创建数据库:
create database task;
创建数据表:
CREATE TABLE email (
ID INT NOT NULL PRIMARY KEY,
Email VARCHAR(255) NOT NULL
);
INSERT INTO email VALUES('1','[email protected]');
INSERT INTO email VALUES('2','[email protected]');
INSERT INTO email VALUES('3','[email protected]');
select Email from email group by Email having count(Email)>1;
创建数据表:
CREATE TABLE World (
name VARCHAR(50) NOT NULL,
continent VARCHAR(50) NOT NULL,
area INT NOT NULL,
population INT NOT NULL,
gdp INT NOT NULL
);
插入数据:
INSERT INTO World
VALUES('Afghanistan','Asia',652230,25500100,20343000);
INSERT INTO World
VALUES('Albania','Europe',28748,2831741,12960000);
INSERT INTO World
VALUES('Algeria','Africa',2381741,37100000,188681000);
INSERT INTO World
VALUES('Andorra','Europe',468,78115,3712000);
INSERT INTO World
VALUES('Angola','Africa',1246700,20609294,100990000);
输出大国(面积超过 300 万平方公里,或者人口超过 2500 万并且 gdp 超过 2000 万)的名称、人口和面积:
select name,population,area
from World
where area > 3000000
or (
population > 25000000
and gdp > 20000000
);