求助~原来没用过MySql 写过存储过程 现在想要为这个界面写个模糊查询的存储过程 下面写的代码虽然语法上面可以通过但是查询不到 需要求助一下大家 delimiter//
create procedure NewSearchInfo6
(
in goodsId varchar(50),
in goodsName_en varchar(50),
in goodsName_cn varchar(50)
)
begin
if goodsId is null and goodsName_en is null and goodsName_cn is null or goodsId = '' and goodsName_en ='' and goodsName_cn = '' then
select * from erp_product;
end if;
if goodsName_cn is null and goodsId is not null and goodsName_en is not null or goodsName_cn ='' or goodsId !='' or goodsName_en !='' then
select * from erp_product where product_id like goodsId and name_en like goodsName_en;
end if;
if goodsName_en is null and goodsId is not null and goodsName_cn is not null or (goodsName_en ='' and goodsId !='' and goodsName_cn !='') then
select * from erp_product where product_id like goodsId and name_cn like goodsName_cn;
end if;
if goodsId is null and goodsName_en is not null and goodsName_cn is not null or (goodsId ='' and goodsName_en !='' and goodsName_cn !='') then
select * from erp_product where name_cn like goodsName_cn and name_en like goodsName_en;
end if;
if goodsName_cn is not null and goodsId is not null and goodsName_en is not null or (goodsName_cn !='' and goodsId !='' and goodsName_en !='') then
select * from erp_product where product_id like goodsId and name_en like goodsName_en and name_cn like goodsName_cn;
end if; if goodsId is not null and goodsName_en is null and goodsName_cn is null or (goodsId !='' and goodsName_en ='' and goodsName_cn ='') then
select * from erp_product where product_id like goodsId;
end if;
if goodsName_en is not null and goodsId is null and goodsName_cn is null or (goodsName_en !='' and goodsId ='' and goodsName_cn ='') then
select * from erp_product where name_en like goodsName_en;
end if;
if goodsName_cn is not null and goodsId is null and goodsName_en is null or (goodsName_cn !='' and goodsId ='' and goodsName_en ='') then
select * from erp_product where name_cn like goodsName_cn;
end if;
end
//
delimiter;
create procedure NewSearchInfo6
(
in goodsId varchar(50),
in goodsName_en varchar(50),
in goodsName_cn varchar(50)
)
begin
if goodsId is null and goodsName_en is null and goodsName_cn is null or goodsId = '' and goodsName_en ='' and goodsName_cn = '' then
select * from erp_product;
end if;
if goodsName_cn is null and goodsId is not null and goodsName_en is not null or goodsName_cn ='' or goodsId !='' or goodsName_en !='' then
select * from erp_product where product_id like goodsId and name_en like goodsName_en;
end if;
if goodsName_en is null and goodsId is not null and goodsName_cn is not null or (goodsName_en ='' and goodsId !='' and goodsName_cn !='') then
select * from erp_product where product_id like goodsId and name_cn like goodsName_cn;
end if;
if goodsId is null and goodsName_en is not null and goodsName_cn is not null or (goodsId ='' and goodsName_en !='' and goodsName_cn !='') then
select * from erp_product where name_cn like goodsName_cn and name_en like goodsName_en;
end if;
if goodsName_cn is not null and goodsId is not null and goodsName_en is not null or (goodsName_cn !='' and goodsId !='' and goodsName_en !='') then
select * from erp_product where product_id like goodsId and name_en like goodsName_en and name_cn like goodsName_cn;
end if; if goodsId is not null and goodsName_en is null and goodsName_cn is null or (goodsId !='' and goodsName_en ='' and goodsName_cn ='') then
select * from erp_product where product_id like goodsId;
end if;
if goodsName_en is not null and goodsId is null and goodsName_cn is null or (goodsName_en !='' and goodsId ='' and goodsName_cn ='') then
select * from erp_product where name_en like goodsName_en;
end if;
if goodsName_cn is not null and goodsId is null and goodsName_en is null or (goodsName_cn !='' and goodsId ='' and goodsName_en ='') then
select * from erp_product where name_cn like goodsName_cn;
end if;
end
//
delimiter;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货