我想知道我是否可以运行这样的请求:
I would like to know if I can run a request like that:
INSERT INTO t2 (a, b)
VALUES (
SELECT a, b
FROM `t1` AS o
WHERE o.id NOT
IN (
SELECT a
FROM t2
)
)
这个想法是用来自 t1 的一些数据填充 t2,但我在语法上一定是错误的.
The idea is to fill the t2 with some data from the t1, but I must be wrong on the syntax.
感谢您的帮助
从 SELECT
语句插入时,不要使用 VALUES
关键字.
You don't use the VALUES
keyword when inserting from a SELECT
statement.
INSERT INTO t2 (a, b)
SELECT a, b
FROM `t1` AS o
WHERE o.id NOT
IN (
SELECT a
FROM t2
)
这篇关于MySql插入一个select的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!