Mysql:如何使用select where子句插入表中

时间:2012-01-15 16:45:09

标签: mysql insert

2作品:

INSERT INTO data._top 
SELECT * FROM data.ops
WHERE ID = 'foo'

使用:

SELECT ID FROM data.table

如何使用Mysql

组合上述2个语句
INSERT INTO data._top 
SELECT  * FROM   data.ops
WHERE     (SELECT ID FROM data.table)

1 个答案:

答案 0 :(得分:1)

你可能会这样:

INSERT INTO `data._top`
    SELECT * FROM `data.ops`
    WHERE `id` IN (SELECT `id` FROM `data.table`);