日期:2014-05-16 浏览次数:21187 次
create temporary table tmp select * from q_templet; update q_templet, tmp set q_templet.p_id = null where q_templet.test_id in ( SELECT tmp.test_id FROM tmp WHERE tmp.e_hold_dt <= '2007-11-21 ' and tmp.templet_status = 1 )
------解决方案--------------------
update q_templet
set p_id = null
where test_id in
(
SELECT test_id FROM q_templet WHERE e_hold_dt <= '2007-11-21' and templet_status = 1
)
MYSQL可以执行啊 。版本低了吧 ?
------解决方案--------------------
这人发了帖子就跑了 :(
------解决方案--------------------
update q_templet
set p_id = null
where test_id in
(
SELECT test_id FROM q_templet WHERE e_hold_dt <= '2007-11-21' and templet_status = 1
)
看你的这条SQL真晕啊,update和子查询都是同一个表q_templet的,那干嘛还要写成这样,直接这样:
update q_templet
set p_id = null
WHERE e_hold_dt <= '2007-11-21' and templet_status = 1
如果是要多表更新,看我发过的帖子,里面我提到了三个方法,你都试试
http://topic.csdn.net/u/20071218/11/69071e9f-085d-4087-890c-c9880cc963ec.html
推荐三个中的第一个