Използвайте INSERT INTO...SELECT
insert into products(productname,proddescription,supplier,lastpurchasedate,quantityleft)
select concat('PID',pid,pname),pdesc,psupp,pdate,pquant
Можете да пропуснете колоната productid
ако е AUTO_INCREMENT
колона.
Чудех се защо трябва да изпълните select pid=last_insert_id();
когато pid
е IN
параметър .
АКТУАЛИЗАЦИЯ 1
DROP PROCEDURE `inserproducts`;
DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `inserproducts`
(
pid int,
pname varchar(50),
pdesc varchar(50),
psupp varchar(50),
pdate date,
pquant int
)
begin
insert into products
(productname,
proddescription,
supplier,
lastpurchasedate,
quantityleft)
select concat('PID',pid,pname), pdesc, psupp, pdate, pquant;
select last_insert_id();
end$$
DELIMITER ;