当前位置:网站首页>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的语句,得到反馈结果。
查询结果
这道题合适于,查询某两个字段大于/小于/等于某个数值的表。
比如我可以建立某个表,查询该表中某个数值过大的情况。
边栏推荐
- [Mori city] random talk on GIS data (I)
- Crunch简介、安装,使用Crunch制作密码字典
- Ffmpeg common commands (2)
- Bao, what if the O & M 100+ server is a headache? Use Xingyun housekeeper!
- 集合对象值改变NULL值对象
- js三元表达式复杂条件判断
- Test self-study people must see: how to find test items in software testing?
- Learning records of building thingsboard, an Internet of things platform
- Oracle物理体系结构
- Botu V16 obtains the system time and converts it into a string
猜你喜欢

Detailed explanation of JUnit unit test framework

Oracle物理体系结构

The use of subplot function in MATLAB

精耕渠道共謀發展 福昕攜手偉仕佳傑開展新產品培訓大會

音视频、编解码相关电子书、小工具,打包奉送!

A brief understanding of white box encryption technology

SIP protocol of gb28181

MySQl的基本使用

XML syntax, constraints

Optaplanner learning notes (I) case cloud balance
随机推荐
Introduction and installation of crunch, and making password dictionary with crunch
微信小程序 navigator点击后有阴影 ,去掉navigator阴影效果
Flutter 实战-快速实现音视频通话应用
Analysis of GetMessage underlying mechanism
OpenCV视频质量诊断----视频遮挡诊断
一文读懂C语言中的结构体
新窗口打开页面-window.open
商业智能BI开发和报表开发有什么本质区别?
118. 杨辉三角
Shell advanced
Native JS creates a calendar - supports mouse wheel scrolling to select months - and can be ported to any framework
2022/5/23-2022/5/30
uni-app微信小程序一键登录获取权限功能
Why has instagram changed from a content sharing platform to a marketing tool? How do independent sellers use this tool?
[Mori city] random talk on GIS data (I)
Introduction to relevant processes and functions of wechat official account development
采集抖音视频
IPv4 address, subnet mask, gateway
ddr4测试-2
How to configure webrtc video streaming format for easygbs, a new version of national standard gb28181 video platform?