Home > Backend Development > PHP Tutorial > 数据库更新某整数字段最小的一条数据, 如何写

数据库更新某整数字段最小的一条数据, 如何写

WBOY
Release: 2016-06-13 11:10:40
Original
1110 people have browsed it

数据库更新某整数字段最小的一条数据, 怎么写?
update tabname set field1='value1' where count in (select min(count) from tabname) limit 1;

这一句会提示:You can't specify target table 'tabname' for update in FROM clause....


------解决方案--------------------
 update tabname set name='value1' where count in (select * from (select min(count) from tabname ) as t) limit 1;

or

update tabname set field1='value1' ORDER BY count ASC LIMIT 1
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template