2


0

SQL Server 2005、構文エラー

この行は機能しません:(問題は最後の行にあります)

SELECT Book_Name
FROM Books
WHERE (Year, Faculty) = (SELECT Year, Faculty FROM Books WHERE Book_Id = 1112);

どうすれば修正できますか?

2 Answer


4


    SELECT b.Book_Name
      FROM Books b
INNER JOIN (Select Year, Faculty From Books Where Book_Id = 1112) b2
        ON b.Year = b2.Year and b.Faculty = b2.Faculty

インナージョインがない場合、代替手段は

SELECT b.Book_Name
  FROM Books b
 WHERE Year In (Select Year From Books Where Book_ID = 1112)
   AND Faculty In (Select Faculty From Books Where Book_ID = 1112)

ただし、宿題の場合は、実際に自分で解決する必要があります :-p


0


参加が最善ですが、できない場合(宿題の制限のため)、これを試してください:

SELECT
    Book_Name
    FROM Books
    WHERE
        Year IN (SELECT Year FROM Books WHERE Book_Id = 1112)
        AND Faculty IN (SELECT Faculty FROM Books WHERE Book_Id = 1112)