---
title: "update where in limit"
author: "zph999"
date: "2011-05-19T13:44:16Z"
tags: []
categories: ["数据库"]
slug: "update-where-in-limit"
draft: false
lastmod: "2011-05-23T11:33:30Z"
id: 1050171
url: "https://zph999.iteye.com/blog/1050171"
---

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关键字，可以在外围套一层。