LanguageId = 1051
所有记录,让我们称之为 A LanguageId != 1051
所有记录,让我们称之为 B B.ModuleName = A.ModuleName
B.Type = A.Type
B.Id = A.Id
B.ParentId = A.ParentId
ModuleName
,Type
,Id
和ParentId
删除集 B 中的重复项(如果全部相同,只留一个(记录)LanguageId = 1051
Translation
表格我可以想象这个过程,但我不知道如何在SQL中实现这一点。
非常感谢任何帮助。
答案 0 :(得分:1)
从集合B中移除所有这些条件:
。等于这个
SELECT *
FROM Translation B
WHERE NOT EXISTS ( SELECT *
FROM Translation A
WHERE
A.LanguageId = 1051
and B.ModuleName = A.ModuleName
and B.Type = A.Type
and B.Id = A.Id
and B.ParentId = A.ParentId
)
and B.LanguageId <> 1051
在集合B中,更改所有LanguageId = 1051
SELECT B.*, 1051 as LenguajeID
FROM Translation B
<.. same as before ...>
将集B插入原始翻译表
INSERT INTO Translation
SELECT [RowId],
[ModuleName],
[Type],
[Id],
[ParentId],
1051 [LanguageId],
[Text],
[X],
[Y],
[Width],
[Height],
[Pending],
[Remarks]
FROM Translation B
WHERE NOT EXISTS ( SELECT *
FROM Translation A
WHERE A.LanguageId = 1051
and B.Type = A.Type
and B.Id = A.Id
and B.ParentId = A.ParentId
and B.ModuleName = A.ModuleName
)
AND B.LanguageId <> 1051
SQL Fiddle Demo仅适用于选择
答案 1 :(得分:0)
insert into transision
select 1051 as LanguageId ,your columns.......
from B
left join A
on B.ModuleName != A.ModuleName and
B.Type != A.Type and
B.Id != A.Id and
B.ParentId != A.ParentId
where B.LanguageId !=1051