0
我有一個查詢,我需要同 不使用IN操作符備選的IN運算符或從查詢中的函數替換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;
我正在使用MYSQL –
你在哪裏使用了IN運算符? –
NEAR CRAETE FUNCTION –