1

如何制作此 select 语句的插入语句?

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

我需要插入 all et= 1;

谢谢

4

3 回答 3

3

编辑 1:

我认为这里有一个答案:在插入查询中使用选择查询以获得相同的表名

为你 :

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

观看文档:

插入 ... 选择语法

文档示例:

INSERT INTO tbl_temp2 (fld_id)
SELECT tbl_temp1.fld_order_id
FROM tbl_temp1 WHERE tbl_temp1.fld_order_id > 100;
于 2013-06-28T10:53:01.187 回答
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%';
于 2013-06-28T10:56:34.093 回答
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%' 
于 2013-06-28T11:01:08.347 回答