创建过程MySQL错误

时间:2016-01-28 01:05:30

标签: mysql stored-procedures

所以我一直在努力做这个简单的过程,但由于某种原因,当我在一个调用语句中运行代码时,它会出现一个错误,说“[ERROR in query 1]结果由多行组成”。我已单独运行过程中的每个语句,它们完美地工作,返回一行。显然我必须在某处出现语法错误。如果有人能够阐明这一点,那就太好了。

    DELIMITER ;;

    CREATE PROCEDURE userInfo(in uID int, out fullname varchar(50), out occupation varchar(50), out NumOrders int(11), out DVDCount int(11), out VehicleCount int(11))
    BEGIN
    SELECT concat(firstname, ' ', lastname) INTO fullname FROM users WHERE userid = uID;

    SELECT occupation into occupation FROM occupation JOIN users ON users.occupationid = occupation.occupationid WHERE userid = uID;

    SELECT count(*) INTO NumOrders FROM orderitem
    JOIN orders ON orders.orderid = orderitem.orderid
    JOIN users ON orders.userid = users.userid
    WHERE users.userid = uID;

    SELECT count(*) INTO DVDCount FROM userDVD WHERE userid = uID;

    SELECT count(*) INTO VehicleCount FROM userVehicle WHERE userid = uID;
    END;;

2 个答案:

答案 0 :(得分:0)

问题是你的 <div>{!! Form::label('roofing1', 'Roofing Material:') !!}</div> <div class="col-sm-4 col-md-4">{!! Form::select('product_code[0]',$roofing,null,['class'=>'form-control','placeholder'=>'None']) !!}</div> <div class="col-sm-2 col-md-2">{!! Form::label('roofing_req1', 'Requirements:') !!}</div> <div class="col-sm-4 col-md-4">{!! Form::text('quantity[0]',null, ['class'=>'form-control', 'id'=>'test']) !!}</div> 是一个字符串可变但你选择了多行。您应该考虑使用临时表(OR)返回结果集,如

out occupation varchar(50)

答案 1 :(得分:0)

DELIMITER ;;

CREATE PROCEDURE userInfo(in uID int, out fullname varchar(50), out occupation varchar(50), out NumOrders int(11), out DVDCount int(11), out VehicleCount int(11))
BEGIN
SELECT concat(firstname, ' ', lastname) INTO fullname FROM users WHERE userid = uID LIMIT 1;

SELECT COALESCE(occupation, 'no occupation') into occupation FROM occupation JOIN users ON users.occupationid = occupation.occupationid WHERE userid = uID LIMIT 1;

SELECT count(*) INTO NumOrders FROM orderitem
JOIN orders ON orders.orderid = orderitem.orderid
JOIN users ON orders.userid = users.userid
WHERE users.userid = uID;

SELECT count(*) INTO DVDCount FROM userDVD WHERE userid = uID;

SELECT count(*) INTO VehicleCount FROM userVehicle WHERE userid = uID;
END;;