SQLite: 如何从table 1 中的列复制数据并根据特定行中数据的ID 将数据粘贴到table 2 中的列?

SQLite: How can I copy data from a column in table 1 and paste the data on a column of table 2 according to IDs of the data in specific rows?

在 TABLE 1 (LEFT SIDED) 中,我在一列 (WordEng) 中有单词列表,并且每个单词都有在另一列 (WordEngID) 中并行列出的唯一 ID。

在 TABLE 2(右侧)中,我有单词 ID 列表,它只是 TABLE 1 中单词的唯一 ID。我想将 TABLE 1 中的单词复制到一列中in TABLE 2 根据其唯一 ID。在 Table 1 中,没有单词具有相同的 ID,而在 Table 2 中,相同的 ID 在不同的行中。

例如,

Table 1 中有一个 ID 为“1807”的词“cut”,我想将其复制并粘贴到 Table 2 中 ID 为“1807”的“words”列中“(在这种情况下是五个)。

您需要此 UPDATE 声明:

UPDATE Table2
SET words = (SELECT t1.WrdEng FROM Table1 t1 WHERE t1.WrdEngId = Table2.WrdEngId)
WHERE words IS NULL

如果您想要更新 words 的所有值,即使它们不是 null,则删除 WHERE 子句。