我有这个表,正在从另一个表中提取数据,我需要从0-10间隔中随机插入其余数据
CREATE TABLE IF NOT EXISTS `Spital`.`Chirurgie` (
`ID Persoanl` INT NOT NULL,
`Doctor` VARCHAR(45) NULL,
`Ore` VARCHAR(45) NULL,
`Pacienti tratati` VARCHAR(45) NULL,
`ID Produse` INT NULL,
`Denumire` VARCHAR(45) NULL,
`Cantitate` INT NULL,
`IdDepartament` INT NULL,
PRIMARY KEY (`ID Persoanl`),
INSERT INTO `spital`.`chirurgie`
(`ID Persoanl`,
`Doctor`,
`Ore`)
SELECT `ID Angajare`,
`Asistent/Medic`,
`Ore lucrate`
FROM `spital`.`personal`
where `Specializare` like '%Chirurgie%' and `Asistent/Medic`like '%Medic%' ;
这是我用来自动填充另一个表中的值的插入代码。
您正在执行查询
INSERT INTO `spital`.`chirurgie`
(`ID Persoanl`,
`Doctor`,
`Ore`,
`Pacienti tratati`,
`ID Produse`,
`Cantitate`)
SELECT `ID Angajare`,
`Asistent/Medic`,
`Ore lucrate`,
floor(rand()*10)+1 as `Pacienti tratati`,
floor(rand()*10)+1 as `ID Produse`,
floor(rand()*10)+1 as `Cantitate`
FROM `spital`.`personal`
where `Specializare` like '%Chirurgie%' and `Asistent/Medic`like '%Medic%' ;