当前位置:网站首页>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)
边栏推荐
- English grammar_ Noun classification
- Analysis of the reasons why enterprises build their own software development teams to use software manpower outsourcing services at the same time
- Multifunctional web file manager filestash
- Kratos微服务框架下实现CQRS架构模式
- Reappearance of ASPP (atlas spatial pyramid pooling) code
- Caddy server agent
- Ping problem between virtual machine and development board
- [enumeration] annoying frogs always step on my rice fields: (who is the most hateful? (POJ hundred practice 2812)
- Summary and Reflection on the third week of winter vacation
- Transformer T5 model read slowly
猜你喜欢
CTO and programmer were both sentenced for losing control of the crawler
How do microservices aggregate API documents? This wave of operation is too good
Data analysis is popular on the Internet, and the full version of "Introduction to data science" is free to download
English grammar_ Noun classification
Bloom filter [proposed by bloom in 1970; redis cache penetration solution]
Xception for deeplab v3+ (including super detailed code comments and original drawing of the paper)
Sensor 调试流程
Caddy server agent
Raft 日志复制
Naoqi robot summary 27
随机推荐
Coordinate layer conversion tool (video)
Image 24 bit depth to 8 bit depth
Sepconv (separable revolution) code recurrence
How to track the real-time trend of Bank of London
189. Rotation array
The vscode code is automatically modified to a compliance code when it is formatted and saved
NFT new opportunity, multimedia NFT aggregation platform okaleido will be launched soon
Xception for deeplab v3+ (including super detailed code comments and original drawing of the paper)
198. Looting - Dynamic Planning
Read the paper glodyne global topology preserving dynamic network embedding
Unsafe类的使用
English grammar_ Adjective / adverb Level 3 - multiple expression
041. (2.10) talk about manpower outsourcing
Enterprise custom form engine solution (12) -- form rule engine 2
G1 garbage collector of garbage collector
What kind of experience is it when the Institute earns 20000 yuan a month?
Usage of laravel conditional array in
Okaleido, a multimedia NFT aggregation platform, is about to go online, and a new NFT era may come
Data analysis is popular on the Internet, and the full version of "Introduction to data science" is free to download
[combinatorics] generating function (commutative property | derivative property | integral property)