我在 SQLITE 数据库中有一个与此类似的表结构,LANID 是另一个表的 FK:
ID LANID TEXT
-------------------------
1 101 Issue1
1 102 Comment1 for Issue1
2 101 Issue2
2 102 Comment1 for Issue2
3 101 Issue3
3 102 Comment1 for Issue3
1 102 Comment2 for Issue1
...
我正在尝试使用以下查询从共享相同 ID 的 TEXT 字段中获取值:
SELECT t.TEXT as issue, s.TEXT as comment
FROM MyTable as t, MyTable as s
WHERE t.LANID = '101' and s.LANID = '102' AND t.ID = s.ID
AND t.TEXT like "%some text in Issue1%"
它几乎可以工作,但有一个问题:它不能在需要时“复制”值。换句话说,我不能像这样显示同一问题的第二条评论:
issue comment
---------------------------------
Issue1 Comment1 for Issue1
Issue1 Comment2 for Issue1
...
提前感谢您的任何提示。