如何在其余列中插入随机值
How can I insert random values in the rest of the columns
我有这个 table 并且正在处理来自另一个 table 的数据,我需要其余的从 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%' ;
这是我用来自动填充其他 table 值的插入代码。
您正在关注
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%' ;
我有这个 table 并且正在处理来自另一个 table 的数据,我需要其余的从 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%' ;
这是我用来自动填充其他 table 值的插入代码。
您正在关注
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%' ;