效果:
代码:
drop procedure if exists test_proc;
create procedure test_proc(carCode varchar(100))
begin
declare title varchar(1000);
declare haveResult boolean default true;
declare result cursor
for
select distinct a.title from t_article_car ac,t_article a,t_article_relation ar
where a.id=ac.article
and ac.car_code like carCode
and a.author=5
and a.is_deleted =false
and a.is_self=false
and a.is_verified=true
and a.id=ar.article
and ar.relation_Type ='User';
declare continue handler for not found set haveResult =false;
open result;
fetch result into title;
while haveResult=true do
select title;
fetch result into title;
end while;
close result;
end;
call test_proc('1040%');