IN运算符的替代或查询中的函数的替换IN运算符?

时间:2016-03-07 07:19:23

标签: mysql sql

我有一个查询,我需要相同的 不使用IN运算符

这是查询

  create function registerStudent(
      in s_id varchar(5),
      in s_courseid varchar (8), 
      in s_secid varchar (8),
      in semester varchar (6), 
      in s_year numeric (4,0),
      out errorMsg varchar(100) returns integer 
      begin 
           declare currEnrol int; 
           select count(*) into currEnrol from takes
           where course_id = s_courseid 
           and secid = s_secid 
           and semester = s_semester 
           and year = s_year; 

           declare limit int; 
           select capacity into limit 
           from classroom 
           natural join section 
           where course_id = s_courseid 
           and secid = s_secid 
           and semester = s_semester 
           and year = s_year; 

           if (currEnrol < limit) begin 
               insert into takes values  (s_id, s_courseid, s_secid, s_semester, s_year, null); 
               return(0); 
           end

          set errorMsg = 'Enrollment limit reached for course ' I I s_courseid II ' section ' I I s_secid; 
          return(-1); 
      end; 

1 个答案:

答案 0 :(得分:0)

列出括号内存储函数的所有参数。默认情况下,所有参数均为<li> xyz </li> 个参数。您无法为参数指定IN修饰符。

IN , OUT or INOUT