我想為自己做一個專案,但我不知道如何從幾乎 2 個具有以下條件的雙表中匯出值,如果庫存一般數量 =<5,則將 id、名稱、數量匯出到緊急表中我的查詢是這樣的一
CREATE TABLE IF NOT EXISTS `Spital`.`Stoc General`
(
`ID Produs` INT,
`Denumire` VARCHAR(45) NOT NULL,
`Cantitate` INT NULL,
PRIMARY KEY (`ID Produs`)
)
ENGINE = InnoDB;
SELECT * FROM `Spital`.`Stoc General`;
INSERT INTO `spital`.`stoc general` (`ID Produs`, `Denumire`, `Cantitate`)
VALUES ('1', 'Clabax', '20');
INSERT INTO `spital`.`stoc general` (`ID Produs`, `Denumire`, `Cantitate`)
VALUES ('2', 'Betadina', '15');
INSERT INTO `spital`.`stoc general` (`ID Produs`, `Denumire`, `Cantitate`)
VALUES ('3', 'Paracetamo', '4');
INSERT INTO `spital`.`stoc general` (`ID Produs`, `Denumire`, `Cantitate`)
VALUES ('4', 'Oxigen', '3');
CREATE TABLE IF NOT EXISTS `Spital`.`Stoc URGENT`
(
`ID Produs` INT NOT NULL AUTO_INCREMENT,
`Denumire` VARCHAR(45) NOT NULL,
`Cantitate` INT NOT NULL,
`Date Delivery` DATETIME NULL,
PRIMARY KEY (`ID Produs`)
)
ENGINE = MEMORY;
uj5u.com熱心網友回復:
使用INSERT INTO 陳述句,使您能夠將資料插入指定的列
INSERT INTO `spital`.`stoc urgent`
(`id produs`,
`denumire`,
`cantitate`)
SELECT `id produs`,
`denumire`,
`cantitate`
FROM `spital`.`stoc general`
where `cantitate`<5
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/438529.html
