如何对此select语句生成insert语句?

SELECT et
 FROM user
      inner join  petrazafa.class_room
      using(id)
where title like '%11%'
   or  title like '%12%';

我需要插入所有et=1;
谢谢

最佳答案

编辑1:
我想这里有个答案:Use select query inside the Insert query for the same table name
为你:

INSERT INTO `yourtable`(et)
SELECT et
FROM user
      inner join  petrazafa.class_room
      using(id)
 where title like '%11%'
      or  title like '%12%';

值班医生:
INSERT ... SELECT Syntax
文档示例:
INSERT INTO tbl_temp2 (fld_id)
SELECT tbl_temp1.fld_order_id
FROM tbl_temp1 WHERE tbl_temp1.fld_order_id > 100;

关于mysql - 通过内部联接的组合插入,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/17362752/

10-11 03:12