当前位置:网站首页>SQL: special update operation
SQL: special update operation
2022-07-03 18:37:00 【"@ book mountain has a path%"】
SQL: Special update operation
Data table code The field accidentally inserts the dimension table (rowid=1) Of desc, To restore .
Data sheet 
Dimension table 
Create table statement
DROP TABLE IF EXISTS `t1`;
CREATE TABLE `t1` (
`id` int(11) NOT NULL,
`code` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ;
INSERT INTO `t1` VALUES (1, 'dd');
INSERT INTO `t1` VALUES (2, 'xx');
INSERT INTO `t1` VALUES (3, 'cc');
INSERT INTO `t1` VALUES (4, ' company ');
INSERT INTO `t1` VALUES (5, ' organization ');
INSERT INTO `t1` VALUES (6, ' department ');
INSERT INTO `t1` VALUES (7, 'dd');
INSERT INTO `t1` VALUES (8, 'xx');
INSERT INTO `t1` VALUES (9, 'cc');
INSERT INTO `t1` VALUES (10, ' company ');
INSERT INTO `t1` VALUES (11, ' organization ');
INSERT INTO `t1` VALUES (12, ' department ');
DROP TABLE IF EXISTS `t2`;
CREATE TABLE `t2` (
`id` int(11) NOT NULL,
`rowid` int(11) NULL DEFAULT NULL,
`code` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`desc` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ;
INSERT INTO `t2` VALUES (1, 1, 'aa', ' company ');
INSERT INTO `t2` VALUES (2, 1, 'bb', ' organization ');
INSERT INTO `t2` VALUES (3, 1, 'yy', ' department ');
INSERT INTO `t2` VALUES (4, 2, 'aa', ' company ');
INSERT INTO `t2` VALUES (5, 2, 'ss', ' organization ');
INSERT INTO `t2` VALUES (6, 2, 'yy', ' department ');
terms of settlement
Query that needs to be updated code, modify desc Corresponding code
UPDATE t1
SET CODE = ( SELECT t2.CODE FROM t2 WHERE t2.DESC = t1.CODE AND rowid = 1 )
WHERE
t1.CODE IN (
SELECT
t2.DESC
FROM
t2
WHERE
rowid = 1)
边栏推荐
- Analysis of the reasons why enterprises build their own software development teams to use software manpower outsourcing services at the same time
- ES7 - Optimization of promise
- Theoretical description of linear equations and summary of methods for solving linear equations by eigen
- 2022-2028 global copper foil (thickness 12 μ M) industry research and trend analysis report
- Multifunctional web file manager filestash
- Day-27 database
- How to draw non overlapping bubble chart in MATLAB
- How to analyze the rising and falling rules of London gold trend chart
- 圖像24比特深度轉8比特深度
- Zero length array
猜你喜欢

Have you learned the correct expression posture of programmers on Valentine's day?

MySQL duplicate check

Opencv learning notes (continuously updated)

Nodejs (01) - introductory tutorial

How do microservices aggregate API documents? This wave of operation is too good

Computer graduation design PHP sports goods online sales system website

Data analysis is popular on the Internet, and the full version of "Introduction to data science" is free to download

Getting started with JDBC

How to analyze the rising and falling rules of London gold trend chart
![Bloom filter [proposed by bloom in 1970; redis cache penetration solution]](/img/f9/27a75454b464d59b9b3465d25fe070.jpg)
Bloom filter [proposed by bloom in 1970; redis cache penetration solution]
随机推荐
[combinatorics] generating function (positive integer splitting | unordered non repeated splitting example)
4. Load balancing and dynamic static separation
php-fpm的max_chindren的一些误区
Theoretical description of linear equations and summary of methods for solving linear equations by eigen
VLAN experiment
[combinatorics] generating function (property summary | important generating function)*
Unity webgl optimization
Boost.Asio Library
199. Right view of binary tree - breadth search
This diversion
SQL injection -day16
The second largest gay dating website in the world was exposed, and the status of programmers in 2022
NFT new opportunity, multimedia NFT aggregation platform okaleido will be launched soon
[combinatorics] exponential generating function (properties of exponential generating function | exponential generating function solving multiple set arrangement)
[combinatorics] generating function (example of using generating function to solve the number of solutions of indefinite equation)
12、 Service management
Caddy server agent
Have you learned the correct expression posture of programmers on Valentine's day?
统计图像中各像素值的数量
Software development freelancer's Road