当前位置:网站首页>MySQL inserts query results into other tables
MySQL inserts query results into other tables
2022-06-10 21:36:00 【Dark horse programmer official】
Learning goals
- Be able to write and insert query results into other tables SQL sentence
1. reflection
There is only one goods surface , We want to add a product classification information , such as : Mobile device classification information , Only pass goods The table cannot complete the addition of commodity classification , So how to add commodity classification information ?
answer :
- Create a commodity classification table , hold goods The commodity classification information in the table is added to the table .
- take goods The classification name in the table is changed to the corresponding classification in the commodity classification table id
2. Create commodity classification table
-- Create commodity classification table
create table good_cates(
id int not null primary key auto_increment,
name varchar(50) not null
);
3. hold goods The commodity classification in the table is added to the commodity classification table
-- Inquire about goods Classification information of commodities in the table
select cate_name from goods group by cate_name;
-- Insert the query results into good_cates In the table
insert into good_cates(name) select cate_name from goods group by cate_name;
-- Add mobile device classification information
insert into good_cates(name) values(' Mobile devices ');
explain :
- insert into .. select .. Express : Insert the query results into the specified table , That is, table replication .
4. Summary
- To complete table replication, you can use : insert into .. select .. SQL sentence
边栏推荐
- 用一个性能提升了666倍的小案例说明在TiDB中正确使用索引的重要性
- Practical | how to use burp suite for password blasting!
- Theoretical basis of distributed services
- 软件测试工程师是做什么的?
- 在YUV图像上根据背景色实现OSD反色
- 自制Table錶格
- Whether there is a simple path from brute force method /u to V
- Construction of RT thread smart win10 64 bit compilation environment
- Shell implements SSH login and executes commands
- A small case with 666 times performance improvement illustrates the importance of using indexes correctly in tidb
猜你喜欢

Redis cache penetration

分布式服务理论基础

Practical | how to use burp suite for password blasting!

72. 编辑距离 ●●●

Construction of RT thread smart win10 64 bit compilation environment

Redis缓存穿透

Quick start to VISSIM simulation

^30h5 web worker multithreading

Software definition boundary (SDP)

CET-6 - Business English - the last recitation before the test
随机推荐
LeetCode 进阶之路 - 136.只出现一次的数字
Leetcode advanced road - 169 Most elements
What should be paid attention to when designing Multilayer PCB?
Redis缓存穿透
从h264实时流中提取Nalu单元数据
在手机上买基金安全吗?会不会被吞本金?
Brute force method / adjacency table depth first directed weighted graph undirected weighted graph
Explain in detail the arithmetic operators related to matrix operation in MATLAB (addition, subtraction, multiplication, division, point multiplication, point division, power)
CCF class a conference or journal - regression related papers
Nanny tutorial: how to become a contributor to Apache linkis documents
^30H5 Web Worker多线程
Monitoring is easy to create a "quasi ecological" pattern and empower Xinchuang to "replace"
Which city should I go to after I graduate from it? Which position has a high salary? Which companies have good treatment?
Read the source code of micropyton - add the C extension class module (2)
shell实现ssh登录并执行命令
你的公司会选择开发数据中台吗?
Acl2022 | bert2bert: an efficient pre training method of parameter reuse, which significantly reduces the training cost of oversized models
Test APK exception control netlocation attacker development
Redis cache avalanche
Use DAP link to download the executable file separately to the mm32f5 microcontroller