MySQL 数据库查询 INSERT

MySQL database query INSERT

我想将数据插入到名为 furesz 的 MySQL 数据库 table 中。我需要向我的查询添加什么,以便我可以将 M-001 插入机器列?

到目前为止我已经有了我的代码 :

INSERT INTO furesz (wood, cubic, width, machine) 
SELECT wood, cubic, width
FROM kobolo
WHERE wood = 'oak' AND width = '0.30' AND length = '0.12'

结果:

machine wood cubic width
oak 0.12 0.30

如果它是固定值,您可以简单地将其添加到查询中:

INSERT INTO furesz (wood, cubic, width, machine) 
SELECT wood, cubic, width, 'M-001'
FROM kobolo
WHERE wood = 'oak' AND width = '0.30' AND length = '0.12'

试一试:

INSERT INTO furesz (wood, cubic, width, machine) 
    SELECT 'oak', cubic, '0.30', 'M-001'
    FROM kobolo
    WHERE wood = 'oak' AND width = '0.30' AND length = '0.12'

或者,也许你可以试试 :

INSERT INTO furesz (wood, cubic, width, machine) 
SELECT wood, cubic, width, machine
FROM kobolo
WHERE machine = 'M-001' wood = 'oak' AND width = '0.30' AND length = '0.12'