2种Mysql连接的update写法
直接使用表连接
update prd_tech a
inner join (select prd_id as pid
from prd_tech
where id = '1422492603039293441') test
set a.`status` = '0'
where a.prd_id = test.pid
以下,由于不能在同一个sql语句中,先select同一个表的某些值,然后再update这个表,所以多加一层查询
update prd_tech
set `status` = '0'
where prd_id = (select a.prd_id
from (select prd_id
from prd_tech
where id = '1422492603039293441') a)