How can I make an insert statement of this select statement?
SELECT et
FROM user
inner join petrazafa.class_room
using(id)
where title like '%11%'
or title like '%12%';
I need to insert into all et
= 1;
thanks
Edit 1 :
I think there's an answer here : Use select query inside the Insert query for the same table name
For you :
INSERT INTO `yourtable`(et)
SELECT et
FROM user
inner join petrazafa.class_room
using(id)
where title like '%11%'
or title like '%12%';
Watch doc :
Doc Exemple :
INSERT INTO tbl_temp2 (fld_id)
SELECT tbl_temp1.fld_order_id
FROM tbl_temp1 WHERE tbl_temp1.fld_order_id > 100;
Try something like
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%';
As I understand you want to update et=1
for title like '%11%' or title like '%12%'
for that
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%'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.