当前位置:网站首页>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的语句,得到反馈结果。
查询结果
这道题合适于,查询某两个字段大于/小于/等于某个数值的表。
比如我可以建立某个表,查询该表中某个数值过大的情况。
边栏推荐
- GC垃圾回收
- Introduction and installation of crunch, and making password dictionary with crunch
- 703. 数据流中的第 K 大元素
- Why has instagram changed from a content sharing platform to a marketing tool? How do independent sellers use this tool?
- 新版国标GB28181视频平台EasyGBS如何配置WebRTC视频流格式播放?
- 通过js实现金字塔(星号金字塔,回文对称数字金字塔)
- pickle. Load error [attributeerror: can't get attribute 'volatile' on < module '\u main']
- AAAI2020: Real-time Scene Text Detection with Differentiable Binarization
- Nat penetration of gb28181
- OpenCV视频质量检测--清晰度检测
猜你喜欢
Solution and summary of Nacos startup failure
GB28181之SIP协议
Optaplanner learning notes (I) case cloud balance
sql查询去重统计的方法总结
XML syntax, constraints
axure不显示元件库
DDR4 test-2
Audio and video, encoding and decoding related e-books, gadgets, packaged for free!
1592 例题1 国王(Sgu223 LOJ10170 LUOGU1896 提高+/省选-) 暴力思考 状压DP 01背包
ubuntu14安装MySQL并配置root账户本地与远程访问
随机推荐
Learning records of building thingsboard, an Internet of things platform
Transaction isolation level gap lock deadlock
Ffmpeg audio related commands
DDR4 test-2
【无标题】
类加载机制
采集抖音视频
ffmpeg常用命令(二)
The key to the success of digital transformation enterprises is to create value with data
利用win7漏洞进行系统登录密码破解
GB28181的NAT穿透
How to configure webrtc video streaming format for easygbs, a new version of national standard gb28181 video platform?
Simplified pinduoduo product data
Solidity - truncated and checked modes of arithmetic operations - new features of 0.8.0
Native JS creates a calendar - supports mouse wheel scrolling to select months - and can be ported to any framework
事务隔离级别 gap锁 死锁
JDBC中如何添加事务
一文读懂C语言中的结构体
IPv4 address, subnet mask, gateway
703. The k-th element in the data flow