如何为这个select语句创建一个insert语句?
SELECT et
FROM user
inner join petrazafa.class_room
using(id)
where title like '%11%'
or title like '%12%';
我需要插入所有et
= 1;
感谢
答案 0 :(得分:3)
编辑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%';
观看文档:
Doc Exemple:
INSERT INTO tbl_temp2 (fld_id)
SELECT tbl_temp1.fld_order_id
FROM tbl_temp1 WHERE tbl_temp1.fld_order_id > 100;
答案 1 :(得分:1)
尝试类似
的内容 INSERT INTO user( 1 as et )
SELECT et
FROM user
inner join petrazafa.class_room
using(id)
where title like '%11%'
or title like '%12%';
答案 2 :(得分:0)
据我了解,您想更新et=1
title like '%11%' or title like '%12%'
表示
update user u inner join petrazafa.class_room c on u.id=c.id set et=1 where title like '%11%'
or title like '%12%'