错误1064(42000):您的SQL语法有错误;检查手册
  对应于您的MySQL服务器版本,以在'(sele
  ct ifnull(count(tbl_Product.manufactureId),0)
                  来自tbl_product,其中manu'在第5行


create procedure ManufactureCheckForDelete(p_manufactureid varchar(50))
begin
    declare p_id longtext ;
    declare p_result longtext;
    set p_id (select ifnull(count(tbl_Product.manufactureId),0)
        from tbl_product where manufactureId = p_manufactureId
    ) ;

    if p_id <> 0 then
    set p_result = 'true' ;
    else
    set p_result = 'false' ;
    end if ;

    select p_result ;
end

最佳答案

您需要使用=运算符来分配查询结果

set p_id (select ifnull(count(tbl_Product.manufactureId),0)
        ^^ here
        from tbl_product where manufactureId = p_manufactureId
    ) ;

set p_id= (select ifnull(count(tbl_Product.manufactureId),0)
        ^^ here
        from tbl_product where manufactureId = p_manufactureId
    ) ;

10-06 06:16