内部联接声明中的SQL SERVER 2008错误

时间:2014-01-09 07:09:14

标签: sql-server

我很难搞清楚错误是什么。此查询为我提供了“关键字'select'附近的语法错误。”任何帮助都可以。谢谢。

select s.id, s.lastname, s.firstname, s.course, c.id, 
       dbo.FUNC_GETDEPARTMENTNAME(c.dept_id) as deptName 
from student s 
inner join course c on s.course = c.id 
where dbo.FUNC_GETDEPARTMENTNAME(c.dept_id) = 'SCHOOL OF ENGINEERING'
      AND s.id in select studno from student_load where right(offer_id,3) = '112'

2 个答案:

答案 0 :(得分:1)

你缺少了parantheses。像这样更改您的查询。

select s.id, s.lastname, s.firstname, s.course, c.id, 
    dbo.FUNC_GETDEPARTMENTNAME(c.dept_id) as deptName from student s inner join 
   course c on s.course = c.id 
    where dbo.FUNC_GETDEPARTMENTNAME(c.dept_id) = 'SCHOOL OF ENGINEERING'
    AND s.id in (select studno from student_load where right(offer_id,3) = '112')

答案 1 :(得分:0)

试试这个,在子查询中缺少括号

 select s.id, s.lastname, s.firstname, s.course, c.id, 
        dbo.FUNC_GETDEPARTMENTNAME(c.dept_id) as deptName from student s inner join 
       course c on s.course = c.id 
        where dbo.FUNC_GETDEPARTMENTNAME(c.dept_id) = 'SCHOOL OF ENGINEERING'
        AND s.id in (select studno from student_load where right(offer_id,3) = '112')