我目前运行此查询:
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 替换
发布评论