0

对于以下查询,我收到此错误:

消息 156,级别 15,状态 1,第 3 行:关键字“in”附近的语法不正确

询问:

SELECT shedule.shedulId, shedule.shedudate, shedule.hometeam, shedule.awayteam
FROM shedule
where in
(Select homeplay.shedulId from homeplay, shedule where shedule.shedulId != homeplay.shedulId);
4

5 回答 5

1

阅读您对另一个回复的评论,我认为您正在寻找这个:

SELECT h.shedulId, 
       s.shedudate, 
       s.hometeam, 
       s.awayteam
FROM   homeplay h 
LEFT OUTER JOIN  
       shedule s ON 
       h.shedulId = s.shedulId
WHERE  s.shedulId IS NULL
于 2013-10-24T08:49:32.140 回答
0

IN的示例用法

SELECT p.FirstName, p.LastName, e.JobTitle
FROM Person.Person p
JOIN HumanResources.Employee AS e
    ON p.BusinessEntityID = e.BusinessEntityID
WHERE e.JobTitle IN ('Design Engineer', 'Tool Designer', 'Marketing Assistant');
GO

详情请看这里

于 2013-10-24T08:48:16.470 回答
0

正确的说法是:

SELECT shedule.shedulId, shedule.shedudate, shedule.hometeam, shedule.awayteam
FROM shedule
WHERE shedule.shedulId IN
(SELECT homeplay.shedulId FROM homeplay, shedule WHERE shedule.shedulId != homeplay.shedulId);
于 2013-10-24T08:48:45.863 回答
0

请试试这个,它会给出你想要的结果

select s.shedulId, s.shedudate, s.hometeam, s.awayteam
from shedule s left join homeplay h on s.shedulId=h.shedulId
where h.shedulId is null
于 2013-10-24T08:49:05.743 回答
0

您需要在 IN 运算符前面有一些东西。

SELECT shedule.shedulId, shedule.shedudate, shedule.hometeam, shedule.awayteam
FROM shedule
where SOMETHING_IS_MISSING_HERE in (Select homeplay.shedulId
                                    from homeplay,shedule
                                    where shedule.shedulId!=homeplay.shedulId)

或者您是否尝试使用 IN 而不是 EXISTS?

于 2013-10-24T08:42:42.600 回答