我已聲明變量(total,order_num,order_stts,id_cust,reMarks)。但是它說錯誤的結果是由多行組成。我該如何解決這個錯誤?請幫我解決這個錯誤,我是新來的sql。錯誤1172:結果包含多個行(在SQL中)
從這個代碼,有幾個任務做:
(1) update tble customer by setting the address to '90 TYT' if c_id= 1
(2) view order_no,status,c_id,item_total remarks.
(3) if item_total 0, then update table order_status by setting remarks = 'UNAVAILABLE',
else select order_no,status,item_total,remarks where status = 'waiting'.
#drop procedure if exists usp_GetAnything;
delimiter //
create procedure usp_GetAnything()
begin
declare total int default 0;
declare order_num varchar(45) default 000;
declare order_stts varchar(45) default 000;
declare id_cust int default 0;
declare reMarks varchar (45) default 000;
select c_id,lname,address,city
from customer;
update customer
set address = '90 TYT'
where c_id = 1;
select o.order_no,o.o_status,c.c_id,o.item_total,o.remarks
into order_num,order_stts,id_cust,total,reMarks
from customer c, order_status o
where c.c_id=o.c_id;
if (total > 0) then
update order_status o
set reMarks = 'UNAVAILABLE'
where order_num > '123';
else
select order_num,order_stts,total,reMarks
from order_status
where order_stts = 'waiting';
end if;
end
非常感謝你@ spencer7593。你幫了我很多!你的解釋是最好的:) – 2014-09-13 06:15:45