MySQL Forums
Forum List  »  General

Re: Concat Prefix with Id and autoincrement it uisng trigger in Mysql
Posted by: Acube solutions
Date: March 18, 2014 11:47AM

can you help me doing it with innodb

I have all most finished, need to concat prefix with the new.Prod_id, can you help me in this



BEGIN

select count(*) into @Product_Name from product_details where Product_Name = NEW.Product_Name;
select Prod_id + 1 into @Prod_id from product_details where Product_Name = NEW.Product_Name order by Prod_Id desc limit 1;
if @Product_Name > 0 then
set NEW.Prod_id = @Prod_id;
else
set NEW.Prod_id = 1;
end if;
SET NEW.Slno = coalesce((select max(Slno) from product_details), 0) + 1;
end

Thanks,
Acube.

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.