Použijte INSERT INTO...SELECT
insert into products(productname,proddescription,supplier,lastpurchasedate,quantityleft)
select concat('PID',pid,pname),pdesc,psupp,pdate,pquant
Sloupec productid
můžete vynechat pokud se jedná o AUTO_INCREMENT
sloupec.
Zajímalo by mě, proč musíte provést select pid=last_insert_id();
když pid
je IN
parametr .
AKTUALIZACE 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 ;