Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 在同一表上链接字段时如何选择记录_Sql_Sql Server - Fatal编程技术网

Sql 在同一表上链接字段时如何选择记录

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

我有一个如下表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.ID = t.QuestionLinkedId
选择*
毫无疑问
左边
连接问题作为链接问题
关于LinkedQuestions.Id=Quetion.QuestionLinkedDid
;
select Question
from Table1
where Id = (
    select QuestionLinkedId
    from Table1
    where Question = 'Question '
)