-3

表名:words
字段:wId、lemma、relatedId
数据:
0 apple 1
1 pie -1

预期结果:
wId = 0
引理 = apple
relatedWord = pie

4

2 回答 2

1

这个查询可以做你想做的事。据我了解,您的表格单词包含relatedld 和 wld 之间的外键。所以这个查询应该满足您的需求:

SELECT t1.wld as wld, 
       t1.lemma as lemma, 
       t2.wld as relatedWorld
FROM words t1 JOIN words t2 ON t1.relatedld = t2.wld;
于 2013-06-06T10:54:32.963 回答
1

你可以参考这里

详情如下:

create table words (wId integer, 
                    lemma varchar(100), 
                    relatedId Integer);
Insert Into words values(0,'apple',1),(1,'pie',-1);

select t1.WID,t1.lemma as Lemma,t2.lemma as relatedWord 
from words t1,words t2
where t1.RelatedID = t2.WID
于 2013-06-06T10:54:56.640 回答