我有3张桌子:
t1
:id,m_id,date t2
:p_id,p_code t3
:p_id,p_code,event_id 如何更新t1
中的ID?
where id in (select p_id from t2 inner join t3 on t2.p_code = t3.p_code)
答案 0 :(得分:0)
UPDATE t1
SET id = (SELECT TOP 1 t2.p_id
FROM t2 INNER JOIN t3
WHERE t2.p_code = t3.p_code)
WHERE <conditon> -- choose rows to update