如何創建此選擇語句的插入語句?用內部連接的組合插入
SELECT et
FROM user
inner join petrazafa.class_room
using(id)
where title like '%11%'
or title like '%12%';
我需要插入所有的et
= 1;
感謝
如何創建此選擇語句的插入語句?用內部連接的組合插入
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%';
關注DOC:
文件爲例:
INSERT INTO tbl_temp2 (fld_id)
SELECT tbl_temp1.fld_order_id
FROM tbl_temp1 WHERE tbl_temp1.fld_order_id > 100;
試着這麼做
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%';
據我瞭解,你要更新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%'
不工作...對不起.. – user2531518
1175 mysql錯誤 – user2531518
是的是id爲共用密鑰...不工作.. 1175錯誤 – user2531518
不起作用 INSERT INTO'user'(ET) SELECT類標識碼 FROM用戶 內使用(ID)加入petrazafa.class_room 其中標題LIKE '%11%' 或標題LIKE '%12%' 值(1); – user2531518