Sql 在同一表上链接字段时如何选择记录
我有一个如下表1:Sql 在同一表上链接字段时如何选择记录,sql,sql-server,Sql,Sql Server,我有一个如下表1: Table1: Id Question QuestionLinkedId 1 question1 3 2 questions2 NULL 3 question3 Null 如果我们给出问题1条件,如何选择问题3记录 我试过: select t.Question from ( select * from Table1 where Question = 'Question ' ) t where t.I
Table1:
Id Question QuestionLinkedId
1 question1 3
2 questions2 NULL
3 question3 Null
如果我们给出问题1条件,如何选择问题3记录
我试过:
select t.Question
from (
select *
from Table1
where Question = 'Question '
) t
where t.ID = t.QuestionLinkedId
选择*
毫无疑问
左边
连接问题作为链接问题
关于LinkedQuestions.Id=Quetion.QuestionLinkedDid
;
select Question
from Table1
where Id = (
select QuestionLinkedId
from Table1
where Question = 'Question '
)