当前位置:网站首页>Basic commands of MySQL
Basic commands of MySQL
2022-07-06 06:41:00 【luckyyuanyuan】
sql Case difference
Create data table :
CREATE TABLE IF NOT EXISTS `runoob_tbl`(
`runoob_id` INT UNSIGNED AUTO_INCREMENT,
`runoob_title` VARCHAR(100) NOT NULL,
`runoob_author` VARCHAR(40) NOT NULL,
`submission_date` DATE,
PRIMARY KEY ( `runoob_id` )
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
1. Set the attribute of the field to NOT NULL, When operating the database, if the data entered in this field is NULL , You're going to report a mistake .
2. AUTO_INCREMENT Define properties that are listed as self incrementing , Generally used for primary key , The value will be added automatically 1.
3. PRIMARY KEY Keywords are used to define columns as primary keys . You can use multiple columns to define the primary key , Columns are separated by commas .
4. ENGINE Set up the storage engine ,CHARSET Set encoding .
According to “PH” Field lookup data , And limit the display of only the first 1000 That's ok
select * from dm_oss.d_f_oss_device_service_info where device_id like '%PH%' limit 1000
Query the values in a column of data ( duplicate removal )
select distinct device_id from dm_oss.d_f_oss_device_service_info where device_id
Specify the inserted column name and value to insert :
INSERT INTO table_name (column1,column2,column3,...)
VALUES (value1,value2,value3,...);
stay “device_id ” The query attribute value in the field contains “PH” The data of , And limit only to show 1000 That's ok
select * from device_service_info where device_id like '%PH%' limit 1000
select * from device_basic_info where device_id like '%PH%' limit 1000
Case a : Multi table joint query and statistics
surface 1:device_service_info
surface 2:device_basic_info
step 1: Inquire about 1.4.9 Version of class
// stay “software_version ” The query attribute value in the field contains “1.4.9” The data of
select device_id, description, software_version from device_basic_info having software_version like '%1.4.9%'
step 2: according to service_start_time Field to select data for a certain period of time
select device_id, service_id from device_service_info having service_start_time between "${day_start}" and "${day_end}"
step 3: Calculate the service times of each device in a specified period of time
select device_id, count(service_id) as service_sum from (select device_id, service_id from device_service_info having service_start_time between "${day_start}" and "${day_end}") group by device_id
step 4: Splice the information of two tables , Adopt internal connection , Take their intersection ;
select t1.device_id, t1.service_sum, t2.description, software_version from ((select device_id, count(service_id) as service_sum from (select device_id, service_id from dm_oss .d_f_oss_device_service_info having service_start_time between "${day_start}" and "${day_end}") group by device_id) t1) inner join ((select device_id, description, software_version from dm_oss.d_f_oss_device_basic_info having software_version like '%1.4.9%') t2 )on t1.device_id = t2.device_id
边栏推荐
- 基於JEECG-BOOT的list頁面的地址欄參數傳遞
- Defense (greed), FBI tree (binary tree)
- What are the characteristics of trademark translation and how to translate it?
- Mise en œuvre d’une fonction complexe d’ajout, de suppression et de modification basée sur jeecg - boot
- Day 245/300 JS foreach data cannot be updated to the object after multi-layer nesting
- Fedora/REHL 安装 semanage
- Py06 字典 映射 字典嵌套 键不存在测试 键排序
- 如何做好金融文献翻译?
- [ 英语 ] 语法重塑 之 动词分类 —— 英语兔学习笔记(2)
- 英语论文翻译成中文字数变化
猜你喜欢
Making interactive page of "left tree and right table" based on jeecg-boot
Engineering organisms containing artificial metalloenzymes perform unnatural biosynthesis
The internationalization of domestic games is inseparable from professional translation companies
[ 英语 ] 语法重塑 之 动词分类 —— 英语兔学习笔记(2)
Today's summer solstice
MySQL5.72.msi安装失败
Traffic encryption of red blue confrontation (OpenSSL encrypted transmission, MSF traffic encryption, CS modifying profile for traffic encryption)
Convert the array selected by El tree into an array object
在JEECG-boot代码生成的基础上修改list页面(结合自定义的组件)
Grouping convolution and DW convolution, residuals and inverted residuals, bottleneck and linearbottleneck
随机推荐
[mqtt from getting started to improving series | 01] quickly build an mqtt test environment from 0 to 1
Black cat takes you to learn UFS protocol Chapter 4: detailed explanation of UFS protocol stack
金融德语翻译,北京专业的翻译公司
How effective is the Chinese-English translation of international economic and trade contracts
E-book CHM online CS
论文翻译英译中,怎样做翻译效果好?
基于JEECG-BOOT的list页面的地址栏参数传递
利用快捷方式-LNK-上线CS
[Yu Yue education] Dunhuang Literature and art reference materials of Zhejiang Normal University
Modify the list page on the basis of jeecg boot code generation (combined with customized components)
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
查询字段个数
How much is the price for the seal of the certificate
ECS accessKey key disclosure and utilization
删除外部表源数据
Avtiviti创建表时报错:Error getting a new connection. Cause: org.apache.commons.dbcp.SQLNestedException
記一個基於JEECG-BOOT的比較複雜的增删改功能的實現
LeetCode每日一题(971. Flip Binary Tree To Match Preorder Traversal)
LeetCode 739. Daily temperature
Market segmentation of supermarket customers based on purchase behavior data (RFM model)