update tb1 a set a.end_date ='2011-05-23' where a.id = (
select h.id from
(
select id from tb2 history
where history.adsite_id =141 and history.en_id=7
order by history.id desc limit 0,1 ) as h
)
update的子条件中不能直接带 limit关键字,可以在外围套一层。
select h.id from
(
select id from tb2 history
where history.adsite_id =141 and history.en_id=7
order by history.id desc limit 0,1 ) as h
)
update的子条件中不能直接带 limit关键字,可以在外围套一层。
SQL更新语句优化
本文介绍了一种在SQL更新语句中使用子查询并结合LIMIT关键字的方法,通过外层包裹查询来规避直接在子条件中使用LIMIT的问题。
1506

被折叠的 条评论
为什么被折叠?



