比较期间使用的 SQL 替换

编程入门 行业动态 更新时间:2024-10-12 01:31:32
本文介绍了比较期间使用的 SQL 替换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我目前运行此查询:

UPDATE table1 SET column1 = table2.columnA FROM table2 WHERE column2 = table2.columnA AND column3 = table2.columnC

是的,有重复的列,抱歉.

Yes there is a duplicate column, sorry.

当我将 column2 与 table2.columnA 交叉引用时,有机会获得 NULL 因为 column2 不包含/,其中table2.columnA 可能包含/

When I cross reference column2 with table2.columnA there is a chance to get NULL because column2 DOES NOT contain / where as table2.columnA may contain /

我不想改变table2.columnA中的数据

据我所知,我可以运行此查询来REPLACE 字符.

It is my understanding that I can run this query to REPLACE the characters.

SELECT REPLACE ([table2.columnA],'/','-') FROM table2

这不会对 table2 造成永久性更改是必要的,所以我想确保我做对了,或者看看是否有更好的方法.

It is necessary that this does not make a permanent change to table2 so I want to make sure that I am getting this right or to see if there is a better way.

现在我想合并这两个查询,但不确定如何合并.

Now I want to combine the two queries but am unsure how.

UPDATE table1 SET column1 = table2.columnA FROM table2 WHERE column2 = (SELECT REPLACE([table2.columnA],'/','-')table2.columnA) FROM table2 AND column3 = table2.columnC

感谢您的帮助!

推荐答案

类似的东西

UPDATE table1 SET column1 = table2.columnA FROM table1 inner join table2 on table1.column2 = REPLACE([table2.columnA],'/','-') and table1.column3 = table2.columnC

更多推荐

比较期间使用的 SQL 替换

本文发布于:2023-11-24 11:45:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1625070.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:SQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!