当前位置:网站首页>SQL 入门计划-1-选择
SQL 入门计划-1-选择
2022-07-01 18:46:00 【南楚巫妖】
从这里开始,将学习如何掌握Leetcode中的SQL题目,每道题目都会有原本和变式两套版本,巩固学习,在实践中提高我的能力。
1 选择
原始版本:

因此,该题目的解答应该如下所示:
第一步:
新建数据库
第二步,
创建数据表:
CREATE TABLE world(
name INT NOT NULL AUTO_INCREMENT,
continent VARCHAR(100) ,
area INT NOT NULL ,
population INT NOT NULL ,
gdp INT NOT NULL ,
PRIMARY KEY (name)
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
在这里,SQL 中主键name的数值类型和真实数值类型不一致。
插入相关数据

INSERT INTO world
(name, continent, area, population, gdp)
VALUES
(1, "a", 3000000,25000000,10);
INSERT INTO world
(name, continent, area, population, gdp)
VALUES
(2, "a", 1000000,15000000,10);
INSERT INTO world
(name, continent, area, population, gdp)
VALUES
(3, "a", 4000000,45000000,10);
INSERT INTO world
(name, continent, area, population, gdp)
VALUES
(4, "a", 5000000,65000000,10);
INSERT INTO world
(name, continent, area, population, gdp)
VALUES
(5, "a", 1000000,5000000,10);
INSERT INTO world
(name, continent, area, population, gdp)
VALUES
(6, "a", 1000000,25000000,10);
INSERT INTO world
(name, continent, area, population, gdp)
VALUES
(7, "a", 13000000,14000000,10);
写查询SQL的语句,得到反馈结果。
查询结果
这道题合适于,查询某两个字段大于/小于/等于某个数值的表。
比如我可以建立某个表,查询该表中某个数值过大的情况。
边栏推荐
- 产品模块化设计的前世今生
- Bao, what if the O & M 100+ server is a headache? Use Xingyun housekeeper!
- 博途V16 获取系统时间转换成字符串
- 703. The k-th element in the data flow
- 【英语语法】Unit1 冠词、名词、代词和数词
- EasyGBS主子码流都为H.265时,切换出现花屏如何解决?
- 类加载机制
- Redo和Undo的区别
- uni-app微信小程序一键登录获取权限功能
- AAAI2020: Real-time Scene Text Detection with Differentiable Binarization
猜你喜欢

ddr4测试-2

Introduction and installation of crunch, and making password dictionary with crunch

EasyGBS网络不稳定情况下重复请求视频拉流问题的优化

sql查询去重统计的方法总结

Case sharing: basic networking configuration of QinQ

新版国标GB28181视频平台EasyGBS如何配置WebRTC视频流格式播放?

118. 杨辉三角

optaplanner学习笔记(一)案例Cloud balance

大厂音视频职位面试题目--今日头条

Crunch简介、安装,使用Crunch制作密码字典
随机推荐
H264编码profile & level控制
2022/6/8-2022/6/12
GetMessage底层机制分析
118. Yanghui triangle
产品模块化设计的前世今生
Task: denial of service DOS
GB28181之SIP协议
Why must we move from Devops to bizdevops?
新增订单如何防止重复提交
类加载机制
Extensive reading of the paper [film: visual reasoning with a general condition layer]
js三元表达式复杂条件判断
axure不显示元件库
Ffmpeg error code
mysql 報錯 Can‘t create table ‘demo01.tb_Student‘ (errno: 150)*
新窗口打开页面-window.open
AAAI2020: Real-time Scene Text Detection with Differentiable Binarization
Optaplanner learning notes (I) case cloud balance
Wechat applet navigator has a shadow after clicking. Remove the shadow effect of navigator
118. 杨辉三角